aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcodl <[email protected]>2017-11-27 20:43:27 +0100
committercodl <[email protected]>2017-11-27 20:43:27 +0100
commiteed6f8f0a4498bf6393c4f79a5dc662c48e98d73 (patch)
tree1c65337c7b6330fb7ac602f009492dae7f93d819 /tests/test_auth.py
parent508d1d2ddd157e02574db1138acda9f3f997f023 (diff)
downloadmastodon.py-eed6f8f0a4498bf6393c4f79a5dc662c48e98d73.tar.gz
add tests for log_in
Diffstat (limited to 'tests/test_auth.py')
-rw-r--r--tests/test_auth.py44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index 3b62a2f..502d825 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -1,7 +1,11 @@
1import pytest
2from mastodon.Mastodon import MastodonIllegalArgumentError
3from mastodon import Mastodon
1try: 4try:
2 from urllib.parse import urlparse, parse_qs 5 from urllib.parse import urlparse, parse_qs
3except ImportError: 6except ImportError:
4 from urlparse import urlparse, parse_qs 7 from urlparse import urlparse, parse_qs
8
5 9
6def test_auth_request_url(api): 10def test_auth_request_url(api):
7 url = api.auth_request_url() 11 url = api.auth_request_url()
@@ -14,3 +18,41 @@ def test_auth_request_url(api):
14 assert set(query['scope'][0].split()) == set(('read', 'write', 'follow')) 18 assert set(query['scope'][0].split()) == set(('read', 'write', 'follow'))
15 19
16 20
21@pytest.mark.vcr()
22def test_log_in_password(api_anonymous):
23 token = api_anonymous.log_in(
24 username='admin@localhost:3000',
25 password='mastodonadmin')
26 assert token
27
28
29@pytest.mark.vcr()
30def test_log_in_password_incorrect(api_anonymous):
31 with pytest.raises(MastodonIllegalArgumentError):
32 api_anonymous.log_in(
33 username='admin@localhost:3000',
34 password='hunter2')
35
36
37@pytest.mark.vcr()
38def test_log_in_password_to_file(api_anonymous, tmpdir):
39 filepath = tmpdir.join('token')
40 api_anonymous.log_in(
41 username='admin@localhost:3000',
42 password='mastodonadmin',
43 to_file=str(filepath))
44 token = filepath.read_text('UTF-8').rstrip()
45 assert token
46 api = api_anonymous
47 api.access_token = token
48 assert api.account_verify_credentials()
49
50
51@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")
52def test_log_in_code(api_anonymous):
53 pass
54
55
56@pytest.mark.skip(reason="Not supported by Mastodon 😬 (yet?)")
57def test_log_in_refresh(api_anonymous):
58 pass
Powered by cgit v1.2.3 (git 2.41.0)