2017-11-27 02:25:33 +01:00
|
|
|
import pytest
|
|
|
|
|
2020-02-22 20:37:54 +01:00
|
|
|
def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="3.1.1", version_check_mode="created"):
|
2017-11-27 14:35:02 +01:00
|
|
|
import mastodon
|
|
|
|
return mastodon.Mastodon(
|
2017-11-27 02:25:33 +01:00
|
|
|
api_base_url='http://localhost:3000',
|
2017-11-29 21:42:20 +01:00
|
|
|
client_id='__MASTODON_PY_TEST_CLIENT_ID',
|
|
|
|
client_secret='__MASTODON_PY_TEST_CLIENT_SECRET',
|
2017-12-11 14:52:03 +01:00
|
|
|
access_token=access_token,
|
2018-05-06 02:26:19 +02:00
|
|
|
mastodon_version=version,
|
2022-06-27 09:47:30 +02:00
|
|
|
version_check_mode=version_check_mode,
|
|
|
|
user_agent='tests/v311')
|
2017-11-29 21:42:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def api():
|
|
|
|
return _api()
|
|
|
|
|
2018-05-06 02:26:19 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def api_low_version():
|
|
|
|
return _api(version="1.2.0", version_check_mode="changed")
|
2017-11-29 21:42:20 +01:00
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def api2():
|
|
|
|
return _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN_2')
|
|
|
|
|
2019-06-22 23:16:47 +02:00
|
|
|
@pytest.fixture
|
|
|
|
def api3():
|
|
|
|
return _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN_3')
|
|
|
|
|
2017-11-27 14:19:21 +01:00
|
|
|
@pytest.fixture
|
2017-11-27 14:35:02 +01:00
|
|
|
def api_anonymous():
|
2017-11-29 21:42:20 +01:00
|
|
|
return _api(access_token=None)
|
2017-11-27 14:19:21 +01:00
|
|
|
|
2018-11-26 11:15:59 +01:00
|
|
|
@pytest.fixture
|
2017-11-27 14:35:02 +01:00
|
|
|
def status(api):
|
|
|
|
_status = api.status_post('Toot!')
|
2017-11-27 02:25:33 +01:00
|
|
|
yield _status
|
2017-11-27 14:35:02 +01:00
|
|
|
api.status_delete(_status['id'])
|
2017-11-27 02:25:33 +01:00
|
|
|
|
2018-11-26 11:15:59 +01:00
|
|
|
@pytest.fixture
|
2018-06-04 20:55:44 +02:00
|
|
|
def status2(api):
|
|
|
|
_status = api.status_post('Toot, too!')
|
|
|
|
yield _status
|
|
|
|
api.status_delete(_status['id'])
|
2017-11-27 04:22:03 +01:00
|
|
|
|
2018-11-26 11:15:59 +01:00
|
|
|
@pytest.fixture(scope="module")
|
2017-11-27 02:25:33 +01:00
|
|
|
def vcr_config():
|
|
|
|
return dict(
|
|
|
|
match_on = ['method', 'path', 'query', 'body'],
|
|
|
|
decode_compressed_response = True
|
|
|
|
)
|