summaryrefslogtreecommitdiff
path: root/tests/conftest.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/conftest.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/conftest.py')
-rw-r--r--tests/conftest.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 43b32f2..bf877e2 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -12,7 +12,7 @@ def push_server():
s.server.shutdown()
s.server.server_close()
-@pytest.fixture
+@pytest.fixture(scope="class")
def mail_server():
s = MailServer()
yield s
@@ -55,17 +55,18 @@ def _account(client, primary, email, mail_server):
email1 = f"test.account-{os.urandom(8).hex()}@test-auth"
email2 = f"test.account2-{os.urandom(8).hex()}@test-auth"
-@pytest.fixture(params=[True, False], ids=["primary", "secondary"])
-def account(client, request, mail_server):
- for a in _account(client, request.param, email1, mail_server):
+@pytest.fixture(params=[True, False], ids=["primary", "secondary"], scope="class")
+def account(request, mail_server):
+ for a in _account(AuthClient(), request.param, email1, mail_server):
yield a
-@pytest.fixture(params=[True, False], ids=["primary", "secondary"])
-def account2(client, request, mail_server):
- for a in _account(client, request.param, email2, mail_server):
+@pytest.fixture(params=[True, False], ids=["primary", "secondary"], scope="class")
+def account2(request, mail_server):
+ for a in _account(AuthClient(), request.param, email2, mail_server):
yield a
-@pytest.fixture
-def unverified_account(client, mail_server):
+@pytest.fixture(scope="class")
+def unverified_account(mail_server):
+ client = AuthClient()
s = client.create_account(email1, "")
yield s
s.destroy_account(s.email, "")
@@ -109,10 +110,14 @@ def account_or_rt(account, request):
yield r
@pytest.fixture
-def forgot_token(account):
+def forgot_token(account, mail_server):
resp = account.post_a("/password/forgot/send_code", { 'email': account.email })
assert 'passwordForgotToken' in resp
assert resp['ttl'] == 300
assert resp['codeLength'] == 16
assert resp['tries'] == 1
- return PasswordChange(account.client, resp['passwordForgotToken'], 'passwordForgotToken')
+ (to, body) = mail_server.wait()
+ assert account.email in to
+ pc = PasswordChange(account.client, resp['passwordForgotToken'], 'passwordForgotToken')
+ pc.code = body.strip()
+ return pc