rename mastodon and mastodon_anonymous fixtures to api, api_anonymous
it was starting to get confusing
This commit is contained in:
pare
cfc9c1ce0c
commit
304145f442
S'han modificat 4 arxius amb 27 adicions i 27 eliminacions
|
@ -1,27 +1,27 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mastodon():
|
def api():
|
||||||
import mastodon as _mastodon
|
import mastodon
|
||||||
return _mastodon.Mastodon(
|
return mastodon.Mastodon(
|
||||||
api_base_url='http://localhost:3000',
|
api_base_url='http://localhost:3000',
|
||||||
client_id='__MASTODON_PY_TEST_ID',
|
client_id='__MASTODON_PY_TEST_ID',
|
||||||
client_secret='__MASTODON_PY_TEST_SECRET',
|
client_secret='__MASTODON_PY_TEST_SECRET',
|
||||||
access_token='__MASTODON_PY_TEST_TOKEN')
|
access_token='__MASTODON_PY_TEST_TOKEN')
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mastodon_anonymous():
|
def api_anonymous():
|
||||||
import mastodon as _mastodon
|
import mastodon
|
||||||
return _mastodon.Mastodon(
|
return mastodon.Mastodon(
|
||||||
api_base_url='http://localhost:3000',
|
api_base_url='http://localhost:3000',
|
||||||
client_id='__MASTODON_PY_TEST_ID',
|
client_id='__MASTODON_PY_TEST_ID',
|
||||||
client_secret='__MASTODON_PY_TEST_SECRET')
|
client_secret='__MASTODON_PY_TEST_SECRET')
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def status(mastodon):
|
def status(api):
|
||||||
_status = mastodon.status_post('Toot!')
|
_status = api.status_post('Toot!')
|
||||||
yield _status
|
yield _status
|
||||||
mastodon.status_delete(_status['id'])
|
api.status_delete(_status['id'])
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
|
|
@ -6,21 +6,21 @@ def test_id_hook(status):
|
||||||
assert isinstance(status['id'], int)
|
assert isinstance(status['id'], int)
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_id_hook_in_reply_to(mastodon, status):
|
def test_id_hook_in_reply_to(api, status):
|
||||||
reply = mastodon.status_post('Reply!', in_reply_to_id=status['id'])
|
reply = api.status_post('Reply!', in_reply_to_id=status['id'])
|
||||||
try:
|
try:
|
||||||
assert isinstance(reply['in_reply_to_id'], int)
|
assert isinstance(reply['in_reply_to_id'], int)
|
||||||
assert isinstance(reply['in_reply_to_account_id'], int)
|
assert isinstance(reply['in_reply_to_account_id'], int)
|
||||||
finally:
|
finally:
|
||||||
mastodon.status_delete(reply['id'])
|
api.status_delete(reply['id'])
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_id_hook_within_reblog(mastodon, status):
|
def test_id_hook_within_reblog(api, status):
|
||||||
reblog = mastodon.status_reblog(status['id'])
|
reblog = api.status_reblog(status['id'])
|
||||||
try:
|
try:
|
||||||
assert isinstance(reblog['reblog']['id'], int)
|
assert isinstance(reblog['reblog']['id'], int)
|
||||||
finally:
|
finally:
|
||||||
mastodon.status_delete(reblog['id'])
|
api.status_delete(reblog['id'])
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_instance(mastodon):
|
def test_instance(api):
|
||||||
instance = mastodon.instance()
|
instance = api.instance()
|
||||||
|
|
||||||
assert isinstance(instance, dict) # hehe, instance is instance
|
assert isinstance(instance, dict) # hehe, instance is instance
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_public_tl_anonymous(mastodon_anonymous, status):
|
def test_public_tl_anonymous(api_anonymous, status):
|
||||||
tl = mastodon_anonymous.timeline_public()
|
tl = api_anonymous.timeline_public()
|
||||||
assert status['id'] in map(lambda st: st['id'], tl)
|
assert status['id'] in map(lambda st: st['id'], tl)
|
||||||
# although tempting, we can't do
|
# although tempting, we can't do
|
||||||
# assert status in tl
|
# assert status in tl
|
||||||
|
@ -10,21 +10,21 @@ def test_public_tl_anonymous(mastodon_anonymous, status):
|
||||||
# pagination-related attributes
|
# pagination-related attributes
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_public_tl(mastodon, status):
|
def test_public_tl(api, status):
|
||||||
tl = mastodon.timeline_public()
|
tl = api.timeline_public()
|
||||||
print(tl[0])
|
print(tl[0])
|
||||||
assert status['id'] in map(lambda st: st['id'], tl)
|
assert status['id'] in map(lambda st: st['id'], tl)
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_home_tl(mastodon, status):
|
def test_home_tl(api, status):
|
||||||
tl = mastodon.timeline_home()
|
tl = api.timeline_home()
|
||||||
assert status['id'] in map(lambda st: st['id'], tl)
|
assert status['id'] in map(lambda st: st['id'], tl)
|
||||||
|
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
def test_hashtag_tl(mastodon):
|
def test_hashtag_tl(api):
|
||||||
status = mastodon.status_post('#hoot (hashtag toot)')
|
status = api.status_post('#hoot (hashtag toot)')
|
||||||
tl = mastodon.timeline_hashtag('hoot')
|
tl = api.timeline_hashtag('hoot')
|
||||||
try:
|
try:
|
||||||
assert status['id'] in map(lambda st: st['id'], tl)
|
assert status['id'] in map(lambda st: st['id'], tl)
|
||||||
finally:
|
finally:
|
||||||
mastodon.status_delete(status['id'])
|
api.status_delete(status['id'])
|
||||||
|
|
Loading…
Referencia en una nova incidència