summaryrefslogtreecommitdiff
path: root/tests/test_auth_account.py
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2022-07-18 17:12:52 +0200
committerpennae <github@quasiparticle.net>2022-07-18 17:12:52 +0200
commita89158377f829720a98342cf434a18b962006ee7 (patch)
tree680e35a2e8e3311d832da336df8cf625c7bf07a7 /tests/test_auth_account.py
parenta4a929218528920c4ae525e2510562dd209f6b3a (diff)
downloadminor-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_auth_account.py')
-rw-r--r--tests/test_auth_account.py99
1 files changed, 50 insertions, 49 deletions
diff --git a/tests/test_auth_account.py b/tests/test_auth_account.py
index 0e7e22d..365a53c 100644
--- a/tests/test_auth_account.py
+++ b/tests/test_auth_account.py
@@ -41,15 +41,16 @@ def test_create_nomail(client):
'message': 'failed to send email'
}
-def test_create_exists(account):
- with pytest.raises(ClientError) as e:
- account.create_account(account.email, "")
- assert e.value.details == {
- 'code': 400,
- 'errno': 101,
- 'error': 'Bad Request',
- 'message': 'account already exists'
- }
+class TestCreateExists:
+ def test_create_exists(self, account):
+ with pytest.raises(ClientError) as e:
+ account.create_account(account.email, "")
+ assert e.value.details == {
+ 'code': 400,
+ 'errno': 101,
+ 'error': 'Bad Request',
+ 'message': 'account already exists'
+ }
@pytest.mark.parametrize("keys", [None, False, True])
@pytest.mark.parametrize("verify", [False, True])
@@ -120,25 +121,26 @@ def test_login_unverified(client, unverified_account):
'message': 'unverified account'
}
-def test_login_badcase(account):
- with pytest.raises(ClientError) as e:
- account.login(account.email.upper(), "")
- assert e.value.details == {
- 'code': 400,
- 'errno': 120,
- 'error': 'Bad Request',
- 'message': 'incorrect email case'
- }
+class TestBadLogin:
+ def test_login_badcase(self, account):
+ with pytest.raises(ClientError) as e:
+ account.login(account.email.upper(), "")
+ assert e.value.details == {
+ 'code': 400,
+ 'errno': 120,
+ 'error': 'Bad Request',
+ 'message': 'incorrect email case'
+ }
-def test_login_badpasswd(account):
- with pytest.raises(ClientError) as e:
- account.login(account.email, "ca0cb780-f114-405a-a5c2-1a4deb933a51")
- assert e.value.details == {
- 'code': 400,
- 'errno': 103,
- 'error': 'Bad Request',
- 'message': 'incorrect password'
- }
+ def test_login_badpasswd(self, account):
+ with pytest.raises(ClientError) as e:
+ account.login(account.email, "ca0cb780-f114-405a-a5c2-1a4deb933a51")
+ assert e.value.details == {
+ 'code': 400,
+ 'errno': 103,
+ 'error': 'Bad Request',
+ 'message': 'incorrect password'
+ }
@pytest.mark.parametrize("keys", [None, False, True])
def test_login(client, account, keys):
@@ -183,25 +185,26 @@ def test_destroy_noaccount(client):
'message': 'unknown account'
}
-def test_destroy_badcase(account):
- with pytest.raises(ClientError) as e:
- account.destroy_account(account.email.upper(), "")
- assert e.value.details == {
- 'code': 400,
- 'errno': 120,
- 'error': 'Bad Request',
- 'message': 'incorrect email case'
- }
+class TestBadDestroy:
+ def test_destroy_badcase(self, account):
+ with pytest.raises(ClientError) as e:
+ account.destroy_account(account.email.upper(), "")
+ assert e.value.details == {
+ 'code': 400,
+ 'errno': 120,
+ 'error': 'Bad Request',
+ 'message': 'incorrect email case'
+ }
-def test_destroy_badpasswd(account):
- with pytest.raises(ClientError) as e:
- account.destroy_account(account.email, "ca0cb780-f114-405a-a5c2-1a4deb933a51")
- assert e.value.details == {
- 'code': 400,
- 'errno': 103,
- 'error': 'Bad Request',
- 'message': 'incorrect password'
- }
+ def test_destroy_badpasswd(self, account):
+ with pytest.raises(ClientError) as e:
+ account.destroy_account(account.email, "ca0cb780-f114-405a-a5c2-1a4deb933a51")
+ assert e.value.details == {
+ 'code': 400,
+ 'errno': 103,
+ 'error': 'Bad Request',
+ 'message': 'incorrect password'
+ }
@pytest.mark.parametrize("auth", [
{},
@@ -224,9 +227,7 @@ def test_keys_invalid(client, auth):
@pytest.fixture
def reset_token(account, forgot_token, mail_server):
- (to, body) = mail_server.wait()
- assert account.email in to
- resp = forgot_token.post_a("/password/forgot/verify_code", { 'code': body.strip() })
+ resp = forgot_token.post_a("/password/forgot/verify_code", { 'code': forgot_token.code })
return AccountReset(account.client, resp['accountResetToken'])
@pytest.mark.parametrize("args", [
@@ -262,7 +263,7 @@ def test_reset(account, reset_token, mail_server, push_server):
}
assert push_server.done()
-def test_reset(account, reset_token, mail_server, push_server):
+def test_reset_twice(account, reset_token, mail_server, push_server):
reset_token.post_a("/account/reset", { 'authPW': auth_pw(account.email, "") })
with pytest.raises(ClientError) as e:
reset_token.post_a("/account/reset", { 'authPW': auth_pw(account.email, "") })