aboutsummaryrefslogtreecommitdiff
blob: 151293981101b0208b2cef795ebfe2504d0972c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import pytest
from mastodon import Mastodon
from mastodon.Mastodon import MastodonIllegalArgumentError

def test_constructor_from_filenames(tmpdir):
    client = tmpdir.join('client')
    client.write_text(u'foo\nbar\n', 'UTF-8')
    access = tmpdir.join('access')
    access.write_text(u'baz\n', 'UTF-8')
    api = Mastodon(
            str(client),
            access_token=str(access))
    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')

def test_constructor_illegal_versioncheckmode():
    with pytest.raises(MastodonIllegalArgumentError):
        api = Mastodon(
                'foo', client_secret='bar',
                version_check_mode='baz')


def test_constructor_missing_client_secret():
    with pytest.raises(MastodonIllegalArgumentError):
        api = Mastodon('foo')

@pytest.mark.vcr()
def test_verify_version(api):
    assert api.verify_minimum_version("2.3.3") == True
    assert api.verify_minimum_version("2.3.4") == False
    assert api.verify_minimum_version("2.4.3") == False
    assert api.verify_minimum_version("3.3.3") == False
    assert api.verify_minimum_version("1.0.0") == True
    
def test_supported_version(api):
    assert Mastodon.get_supported_version()
Powered by cgit v1.2.3 (git 2.41.0)