mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
move aurweb.testing to its own package
+ Added aurweb.testing.setup_test_db(*tables) + Added aurweb.testing.models.make_user(**kwargs) + Added aurweb.testing.models.make_session(**kwargs) + Added aurweb.testing.requests.Client + Added aurweb.testing.requests.Request * Updated test_l10n.py to use our new Request Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
64bc93926f
commit
5185df629e
4 changed files with 41 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
from aurweb.db import get_engine
|
||||
import aurweb.db
|
||||
|
||||
|
||||
def setup_test_db(*args):
|
||||
|
@ -21,7 +21,7 @@ def setup_test_db(*args):
|
|||
test_tables = ["Users", "Sessions"];
|
||||
setup_test_db(*test_tables)
|
||||
"""
|
||||
engine = get_engine()
|
||||
engine = aurweb.db.get_engine()
|
||||
conn = engine.connect()
|
||||
|
||||
tables = list(args)
|
25
aurweb/testing/models.py
Normal file
25
aurweb/testing/models.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import warnings
|
||||
|
||||
from sqlalchemy import exc
|
||||
|
||||
import aurweb.db
|
||||
|
||||
|
||||
def make_user(**kwargs):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", exc.SAWarning)
|
||||
from aurweb.models.user import User
|
||||
user = User(**kwargs)
|
||||
aurweb.db.session.add(user)
|
||||
aurweb.db.session.commit()
|
||||
return user
|
||||
|
||||
|
||||
def make_session(**kwargs):
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", exc.SAWarning)
|
||||
from aurweb.models.session import Session
|
||||
session = Session(**kwargs)
|
||||
aurweb.db.session.add(session)
|
||||
aurweb.db.session.commit()
|
||||
return session
|
8
aurweb/testing/requests.py
Normal file
8
aurweb/testing/requests.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
class Client:
|
||||
host = "127.0.0.1"
|
||||
|
||||
|
||||
class Request:
|
||||
client = Client()
|
||||
cookies = dict()
|
||||
headers = dict()
|
Loading…
Add table
Add a link
Reference in a new issue