diff options
author | pennae <github@quasiparticle.net> | 2022-07-18 17:12:52 +0200 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-07-18 17:12:52 +0200 |
commit | a89158377f829720a98342cf434a18b962006ee7 (patch) | |
tree | 680e35a2e8e3311d832da336df8cf625c7bf07a7 /tests/test_oauth.py | |
parent | a4a929218528920c4ae525e2510562dd209f6b3a (diff) | |
download | minor-skulk-a89158377f829720a98342cf434a18b962006ee7.tar.gz minor-skulk-a89158377f829720a98342cf434a18b962006ee7.tar.xz minor-skulk-a89158377f829720a98342cf434a18b962006ee7.zip |
speed up test suite
mostly by grouping tests that can reuse the same account (which is
expensive to create) into classes and scoping accounts to classes.
Diffstat (limited to 'tests/test_oauth.py')
-rw-r--r-- | tests/test_oauth.py | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/tests/test_oauth.py b/tests/test_oauth.py index 3eb32ac..d809113 100644 --- a/tests/test_oauth.py +++ b/tests/test_oauth.py @@ -32,66 +32,67 @@ def test_destroy_invalid(oauth, args, code, errno, error, message): oauth.post("/destroy", args) assert e.value.details == {'code': code, 'errno': errno, 'error': error, 'message': message} -def test_destroy_access(oauth, access_token): - oauth.post("/verify", {'token': access_token}) - oauth.post("/destroy", {'access_token': access_token}) - with pytest.raises(ClientError) as e: +class TestOauth: + def test_destroy_access(self, oauth, access_token): oauth.post("/verify", {'token': access_token}) - assert e.value.details == { - 'code': 400, - 'errno': 109, - 'error': 'Bad Request', - 'message': 'invalid request parameter' - } + oauth.post("/destroy", {'access_token': access_token}) + with pytest.raises(ClientError) as e: + oauth.post("/verify", {'token': access_token}) + assert e.value.details == { + 'code': 400, + 'errno': 109, + 'error': 'Bad Request', + 'message': 'invalid request parameter' + } -def test_destroy_refresh(oauth, refresh_token): - refresh_token.get_a("/account/devices") - oauth.post("/destroy", {'refresh_token': refresh_token.bearer}) - with pytest.raises(ClientError) as e: + def test_destroy_refresh(self, oauth, refresh_token): refresh_token.get_a("/account/devices") - assert e.value.details == { - 'code': 401, - 'errno': 109, - 'error': 'Unauthorized', - 'message': 'invalid request signature' - } + oauth.post("/destroy", {'refresh_token': refresh_token.bearer}) + with pytest.raises(ClientError) as e: + refresh_token.get_a("/account/devices") + assert e.value.details == { + 'code': 401, + 'errno': 109, + 'error': 'Unauthorized', + 'message': 'invalid request signature' + } -def test_destroy_any(oauth, access_token, refresh_token): - oauth.post("/verify", {'token': access_token}) - oauth.post("/destroy", {'token': access_token}) - with pytest.raises(ClientError) as e: + def test_destroy_any(self, oauth, access_token, refresh_token): oauth.post("/verify", {'token': access_token}) - assert e.value.details == { - 'code': 400, - 'errno': 109, - 'error': 'Bad Request', - 'message': 'invalid request parameter' - } + oauth.post("/destroy", {'token': access_token}) + with pytest.raises(ClientError) as e: + oauth.post("/verify", {'token': access_token}) + assert e.value.details == { + 'code': 400, + 'errno': 109, + 'error': 'Bad Request', + 'message': 'invalid request parameter' + } - refresh_token.get_a("/account/devices") - oauth.post("/destroy", {'token': refresh_token.bearer}) - with pytest.raises(ClientError) as e: refresh_token.get_a("/account/devices") - assert e.value.details == { - 'code': 401, - 'errno': 109, - 'error': 'Unauthorized', - 'message': 'invalid request signature' - } + oauth.post("/destroy", {'token': refresh_token.bearer}) + with pytest.raises(ClientError) as e: + refresh_token.get_a("/account/devices") + assert e.value.details == { + 'code': 401, + 'errno': 109, + 'error': 'Unauthorized', + 'message': 'invalid request signature' + } -def test_oauth_verify(account, oauth, access_token): - assert oauth.post("/verify", {'token': access_token}) == { - 'user': account.props['uid'], - 'client_id': "5882386c6d801776", - 'scope': ['profile'], - } + def test_oauth_verify(self, account, oauth, access_token): + assert oauth.post("/verify", {'token': access_token}) == { + 'user': account.props['uid'], + 'client_id': "5882386c6d801776", + 'scope': ['profile'], + } -def test_oauth_verify_refresh(oauth, refresh_token): - with pytest.raises(ClientError) as e: - oauth.post("/verify", {'token': refresh_token.bearer}) - assert e.value.details == { - 'code': 400, - 'errno': 109, - 'error': 'Bad Request', - 'message': 'invalid request parameter' - } + def test_oauth_verify_refresh(self, oauth, refresh_token): + with pytest.raises(ClientError) as e: + oauth.post("/verify", {'token': refresh_token.bearer}) + assert e.value.details == { + 'code': 400, + 'errno': 109, + 'error': 'Bad Request', + 'message': 'invalid request parameter' + } |