source/projects/tentacles/test/python/conftest.py

49 lines
941 B
Python
Raw Normal View History

2023-05-13 22:58:17 +00:00
#!/usr/bin/env python3
from datetime import timedelta
import pytest
2023-05-28 23:21:05 +00:00
import tentacles.store as s
2023-05-13 22:58:17 +00:00
@pytest.yield_fixture
def store():
conn = s.Store(":memory:")
conn.connect()
yield conn
conn.close()
@pytest.fixture
def username_testy():
return "testy@test.com"
@pytest.fixture
def password_testy():
return "testpw"
@pytest.fixture
2023-06-03 19:20:05 +00:00
def uid_testy(store: s.Store, username_testy, password_testy):
with store.savepoint():
return store.try_create_user(
username=username_testy,
email=username_testy,
password=password_testy,
sid=1,
).id
2023-05-13 22:58:17 +00:00
@pytest.fixture
def login_ttl():
return timedelta(hours=12)
@pytest.fixture
def sid_testy(store, uid_testy, username_testy, password_testy, login_ttl):
2023-06-03 19:20:05 +00:00
with store.savepoint():
return store.try_login(
username=username_testy, password=password_testy, ttl=login_ttl
).id