2017-11-27 14:19:21 +01:00
|
|
|
import pytest
|
2018-01-03 11:44:14 +01:00
|
|
|
from mastodon.Mastodon import MastodonAPIError,\
|
|
|
|
MastodonIllegalArgumentError,\
|
|
|
|
MastodonUnauthorizedError
|
2017-11-27 14:19:21 +01:00
|
|
|
|
|
|
|
@pytest.mark.vcr()
|
2017-11-27 14:35:02 +01:00
|
|
|
def test_public_tl_anonymous(api_anonymous, status):
|
|
|
|
tl = api_anonymous.timeline_public()
|
2017-11-27 14:19:21 +01:00
|
|
|
assert status['id'] in map(lambda st: st['id'], tl)
|
|
|
|
# although tempting, we can't do
|
|
|
|
# assert status in tl
|
|
|
|
# because the statuses returned in the tl have additional
|
|
|
|
# pagination-related attributes
|
|
|
|
|
|
|
|
@pytest.mark.vcr()
|
2017-11-27 14:35:02 +01:00
|
|
|
def test_public_tl(api, status):
|
2017-11-27 15:26:20 +01:00
|
|
|
public = api.timeline_public()
|
|
|
|
local = api.timeline_local()
|
|
|
|
assert status['id'] in map(lambda st: st['id'], public)
|
|
|
|
assert status['id'] in map(lambda st: st['id'], local)
|
2017-11-27 14:19:21 +01:00
|
|
|
|
2018-01-03 11:44:14 +01:00
|
|
|
@pytest.mark.vcr()
|
|
|
|
def test_unauthed_home_tl_throws(api_anonymous, status):
|
|
|
|
with pytest.raises(MastodonUnauthorizedError):
|
|
|
|
api_anonymous.timeline_home()
|
|
|
|
|
2017-11-27 14:19:21 +01:00
|
|
|
@pytest.mark.vcr()
|
2017-11-27 14:35:02 +01:00
|
|
|
def test_home_tl(api, status):
|
|
|
|
tl = api.timeline_home()
|
2017-11-27 14:19:21 +01:00
|
|
|
assert status['id'] in map(lambda st: st['id'], tl)
|
|
|
|
|
|
|
|
@pytest.mark.vcr()
|
2017-11-27 14:35:02 +01:00
|
|
|
def test_hashtag_tl(api):
|
|
|
|
status = api.status_post('#hoot (hashtag toot)')
|
|
|
|
tl = api.timeline_hashtag('hoot')
|
2017-11-27 14:19:21 +01:00
|
|
|
try:
|
|
|
|
assert status['id'] in map(lambda st: st['id'], tl)
|
|
|
|
finally:
|
2017-11-27 14:35:02 +01:00
|
|
|
api.status_delete(status['id'])
|
2017-11-27 14:35:56 +01:00
|
|
|
|
2017-11-29 22:34:13 +01:00
|
|
|
def test_hashtag_tl_leading_hash(api):
|
|
|
|
with pytest.raises(MastodonIllegalArgumentError):
|
|
|
|
api.timeline_hashtag('#hoot')
|
|
|
|
|
|
|
|
|
2017-11-27 14:35:56 +01:00
|
|
|
@pytest.mark.vcr()
|
|
|
|
def test_home_tl_anonymous_throws(api_anonymous):
|
|
|
|
with pytest.raises(MastodonAPIError):
|
2017-11-29 22:34:13 +01:00
|
|
|
api_anonymous.timeline_home()
|