aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_auth.py30
-rw-r--r--tests/test_create_app.py2
2 files changed, 27 insertions, 5 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index b4a004e..fbf8974 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -30,7 +30,6 @@ def test_log_in_password(api_anonymous):
30 password='mastodonadmin') 30 password='mastodonadmin')
31 assert token 31 assert token
32 32
33
34@pytest.mark.vcr() 33@pytest.mark.vcr()
35def test_log_in_password_incorrect(api_anonymous): 34def test_log_in_password_incorrect(api_anonymous):
36 with pytest.raises(MastodonIllegalArgumentError): 35 with pytest.raises(MastodonIllegalArgumentError):
@@ -38,7 +37,6 @@ def test_log_in_password_incorrect(api_anonymous):
38 username='admin@localhost', 37 username='admin@localhost',
39 password='hunter2') 38 password='hunter2')
40 39
41
42@pytest.mark.vcr() 40@pytest.mark.vcr()
43def test_log_in_password_to_file(api_anonymous, tmpdir): 41def test_log_in_password_to_file(api_anonymous, tmpdir):
44 filepath = tmpdir.join('token') 42 filepath = tmpdir.join('token')
@@ -46,18 +44,42 @@ def test_log_in_password_to_file(api_anonymous, tmpdir):
46 username='admin@localhost', 44 username='admin@localhost',
47 password='mastodonadmin', 45 password='mastodonadmin',
48 to_file=str(filepath)) 46 to_file=str(filepath))
49 token = filepath.read_text('UTF-8').rstrip() 47 token = filepath.read_text('UTF-8').rstrip().split("\n")[0]
50 assert token 48 assert token
51 api = api_anonymous 49 api = api_anonymous
52 api.access_token = token 50 api.access_token = token
53 assert api.account_verify_credentials() 51 assert api.account_verify_credentials()
54 52
53@pytest.mark.vcr()
54def test_url_errors(tmpdir):
55 clientid_good = tmpdir.join("clientid")
56 token_good = tmpdir.join("token")
57 clientid_bad = tmpdir.join("clientid_bad")
58 token_bad = tmpdir.join("token_bad")
59
60 clientid_good.write_text("foo\nbar\nhttps://zombo.com\n", "UTF-8")
61 token_good.write_text("foo\nhttps://zombo.com\n", "UTF-8")
62 clientid_bad.write_text("foo\nbar\nhttps://evil.org\n", "UTF-8")
63 token_bad.write_text("foo\nhttps://evil.org\n", "UTF-8")
64
65 api = Mastodon(client_id = clientid_good, access_token = token_good)
66 assert api
67 assert api.api_base_url == "https://zombo.com"
68 assert Mastodon(client_id = clientid_good, access_token = token_good, api_base_url = "zombo.com")
69
70 with pytest.raises(MastodonIllegalArgumentError):
71 Mastodon(client_id = clientid_good, access_token = token_bad, api_base_url = "zombo.com")
72
73 with pytest.raises(MastodonIllegalArgumentError):
74 Mastodon(client_id = clientid_bad, access_token = token_good, api_base_url = "zombo.com")
75
76 with pytest.raises(MastodonIllegalArgumentError):
77 Mastodon(client_id = clientid_bad, access_token = token_bad, api_base_url = "zombo.com")
55 78
56@pytest.mark.skip(reason="Not sure how to test this without setting up selenium or a similar browser automation suite to click on the allow button") 79@pytest.mark.skip(reason="Not sure how to test this without setting up selenium or a similar browser automation suite to click on the allow button")
57def test_log_in_code(api_anonymous): 80def test_log_in_code(api_anonymous):
58 pass 81 pass
59 82
60
61@pytest.mark.skip(reason="Not supported by Mastodon >:@ (yet?)") 83@pytest.mark.skip(reason="Not supported by Mastodon >:@ (yet?)")
62def test_log_in_refresh(api_anonymous): 84def test_log_in_refresh(api_anonymous):
63 pass 85 pass
diff --git a/tests/test_create_app.py b/tests/test_create_app.py
index b9de298..8260751 100644
--- a/tests/test_create_app.py
+++ b/tests/test_create_app.py
@@ -31,7 +31,7 @@ def test_create_app(mocker, to_file=None, redirect_uris=None, website=None):
31def test_create_app_to_file(mocker, tmpdir): 31def test_create_app_to_file(mocker, tmpdir):
32 filepath = tmpdir.join('credentials') 32 filepath = tmpdir.join('credentials')
33 test_create_app(mocker, to_file=str(filepath)) 33 test_create_app(mocker, to_file=str(filepath))
34 assert filepath.read_text('UTF-8') == "foo\nbar\n" 34 assert filepath.read_text('UTF-8') == "foo\nbar\nhttps://example.com\n"
35 35
36def test_create_app_redirect_uris(mocker): 36def test_create_app_redirect_uris(mocker):
37 test_create_app(mocker, redirect_uris='http://example.net') 37 test_create_app(mocker, redirect_uris='http://example.net')
Powered by cgit v1.2.3 (git 2.41.0)