2017-11-27 15:18:18 +01:00
|
|
|
import pytest
|
|
|
|
from mastodon import Mastodon
|
|
|
|
from mastodon.Mastodon import MastodonIllegalArgumentError
|
|
|
|
|
2017-11-27 17:47:15 +01:00
|
|
|
def test_constructor_from_filenames(tmpdir):
|
|
|
|
client = tmpdir.join('client')
|
2017-11-27 20:51:12 +01:00
|
|
|
client.write_text(u'foo\nbar\n', 'UTF-8')
|
2017-11-27 17:47:15 +01:00
|
|
|
access = tmpdir.join('access')
|
2017-11-27 20:51:12 +01:00
|
|
|
access.write_text(u'baz\n', 'UTF-8')
|
2017-11-27 15:18:18 +01:00
|
|
|
api = Mastodon(
|
2017-11-27 17:47:15 +01:00
|
|
|
str(client),
|
2017-11-27 20:51:12 +01:00
|
|
|
access_token=str(access))
|
2017-11-27 15:18:18 +01:00
|
|
|
assert api.client_id == 'foo'
|
|
|
|
assert api.client_secret == 'bar'
|
|
|
|
assert api.access_token == 'baz'
|
|
|
|
|
|
|
|
def test_constructor_illegal_ratelimit():
|
|
|
|
with pytest.raises(MastodonIllegalArgumentError):
|
|
|
|
api = Mastodon(
|
|
|
|
'foo', client_secret='bar',
|
|
|
|
ratelimit_method='baz')
|
|
|
|
|
2018-05-06 02:50:54 +02:00
|
|
|
def test_constructor_illegal_versioncheckmode():
|
|
|
|
with pytest.raises(MastodonIllegalArgumentError):
|
|
|
|
api = Mastodon(
|
|
|
|
'foo', client_secret='bar',
|
|
|
|
version_check_mode='baz')
|
|
|
|
|
|
|
|
|
2017-11-27 15:18:18 +01:00
|
|
|
def test_constructor_missing_client_secret():
|
|
|
|
with pytest.raises(MastodonIllegalArgumentError):
|
|
|
|
api = Mastodon('foo')
|
2018-05-06 02:50:54 +02:00
|
|
|
|
|
|
|
@pytest.mark.vcr()
|
|
|
|
def test_verify_version(api):
|
|
|
|
assert api.verify_minimum_version("2.3.3") == True
|
2018-06-05 22:10:31 +02:00
|
|
|
assert api.verify_minimum_version("9999.9999.9999") == False
|
2018-05-06 02:50:54 +02:00
|
|
|
assert api.verify_minimum_version("1.0.0") == True
|
2018-06-04 20:55:44 +02:00
|
|
|
|
|
|
|
def test_supported_version(api):
|
|
|
|
assert Mastodon.get_supported_version()
|