rename mastodon and mastodon_anonymous fixtures to api, api_anonymous

it was starting to get confusing
This commit is contained in:
codl 2017-11-27 14:35:02 +01:00
pare cfc9c1ce0c
commit 304145f442
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 6CD7C8891ED1233A
S'han modificat 4 arxius amb 27 adicions i 27 eliminacions

Veure arxiu

@ -1,27 +1,27 @@
import pytest
@pytest.fixture
def mastodon():
import mastodon as _mastodon
return _mastodon.Mastodon(
def api():
import mastodon
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID',
client_secret='__MASTODON_PY_TEST_SECRET',
access_token='__MASTODON_PY_TEST_TOKEN')
@pytest.fixture
def mastodon_anonymous():
import mastodon as _mastodon
return _mastodon.Mastodon(
def api_anonymous():
import mastodon
return mastodon.Mastodon(
api_base_url='http://localhost:3000',
client_id='__MASTODON_PY_TEST_ID',
client_secret='__MASTODON_PY_TEST_SECRET')
@pytest.fixture()
def status(mastodon):
_status = mastodon.status_post('Toot!')
def status(api):
_status = api.status_post('Toot!')
yield _status
mastodon.status_delete(_status['id'])
api.status_delete(_status['id'])
@pytest.fixture()

Veure arxiu

@ -6,21 +6,21 @@ def test_id_hook(status):
assert isinstance(status['id'], int)
@pytest.mark.vcr()
def test_id_hook_in_reply_to(mastodon, status):
reply = mastodon.status_post('Reply!', in_reply_to_id=status['id'])
def test_id_hook_in_reply_to(api, status):
reply = api.status_post('Reply!', in_reply_to_id=status['id'])
try:
assert isinstance(reply['in_reply_to_id'], int)
assert isinstance(reply['in_reply_to_account_id'], int)
finally:
mastodon.status_delete(reply['id'])
api.status_delete(reply['id'])
@pytest.mark.vcr()
def test_id_hook_within_reblog(mastodon, status):
reblog = mastodon.status_reblog(status['id'])
def test_id_hook_within_reblog(api, status):
reblog = api.status_reblog(status['id'])
try:
assert isinstance(reblog['reblog']['id'], int)
finally:
mastodon.status_delete(reblog['id'])
api.status_delete(reblog['id'])
@pytest.mark.vcr()

Veure arxiu

@ -1,8 +1,8 @@
import pytest
@pytest.mark.vcr()
def test_instance(mastodon):
instance = mastodon.instance()
def test_instance(api):
instance = api.instance()
assert isinstance(instance, dict) # hehe, instance is instance

Veure arxiu

@ -1,8 +1,8 @@
import pytest
@pytest.mark.vcr()
def test_public_tl_anonymous(mastodon_anonymous, status):
tl = mastodon_anonymous.timeline_public()
def test_public_tl_anonymous(api_anonymous, status):
tl = api_anonymous.timeline_public()
assert status['id'] in map(lambda st: st['id'], tl)
# although tempting, we can't do
# assert status in tl
@ -10,21 +10,21 @@ def test_public_tl_anonymous(mastodon_anonymous, status):
# pagination-related attributes
@pytest.mark.vcr()
def test_public_tl(mastodon, status):
tl = mastodon.timeline_public()
def test_public_tl(api, status):
tl = api.timeline_public()
print(tl[0])
assert status['id'] in map(lambda st: st['id'], tl)
@pytest.mark.vcr()
def test_home_tl(mastodon, status):
tl = mastodon.timeline_home()
def test_home_tl(api, status):
tl = api.timeline_home()
assert status['id'] in map(lambda st: st['id'], tl)
@pytest.mark.vcr()
def test_hashtag_tl(mastodon):
status = mastodon.status_post('#hoot (hashtag toot)')
tl = mastodon.timeline_hashtag('hoot')
def test_hashtag_tl(api):
status = api.status_post('#hoot (hashtag toot)')
tl = api.timeline_hashtag('hoot')
try:
assert status['id'] in map(lambda st: st['id'], tl)
finally:
mastodon.status_delete(status['id'])
api.status_delete(status['id'])