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

57 lines
1.0 KiB
Python

from unittest.mock import patch
import pytest
from flask_login.test_client import FlaskLoginClient
from htmx_contact import create_app
from htmx_contact.config import ContactSettings
from htmx_contact.models import User
@pytest.fixture()
def test_config():
return ContactSettings(SECRET_KEY=b"secrettestingvalue")
@pytest.fixture()
def test_user():
return User(id=1, primary_email="test", password="test", username="test")
@pytest.fixture()
def app(test_config):
app = create_app(config=test_config)
app.test_client_class = FlaskLoginClient
app.config.update(
{
"TESTING": True,
}
)
# other setup can go here
yield app
# clean up / reset resources here
@pytest.fixture()
def anynomous_client(app):
return app.test_client()
@pytest.fixture()
def client(app, test_user):
return app.test_client(user=test_user)
@pytest.fixture()
def runner(app):
return app.test_cli_runner()
@pytest.fixture()
def sqla_session():
with patch("htmx_contact.Session") as ms:
yield ms