You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
941 B

from contextlib import contextmanager
from dataclasses import dataclass
from pathlib import Path
from typing import Iterator
from flask import Flask
from flask import Response
from flask.testing import FlaskClient
from monsun_backend import access
from monsun_backend import create_app
from monsun_backend import database
TESTS_DIR = Path(__file__).parent
@contextmanager
def setup_app() -> Iterator[Flask]:
app: Flask = create_app()
app.config["SERVER_NAME"] = "monsun_backend.localdomain"
app.config["TESTING"] = True
# binds the app to the current context
with app.app_context():
# create all tables
database.db.create_all()
access.make_admin_user()
yield app
with app.app_context():
# drop all tables
database.db.session.remove()
database.db.drop_all()
@dataclass
class TestUser:
__test__ = False
response: Response
client: FlaskClient