Add basic server unit tests
This commit is contained in:
parent
3ab6e2c48d
commit
dd144bf207
@ -8,6 +8,8 @@ import amanuensis.backend.character as charq
|
||||
import amanuensis.backend.lexicon as lexiq
|
||||
import amanuensis.backend.membership as memq
|
||||
import amanuensis.backend.user as userq
|
||||
from amanuensis.config import AmanuensisConfig
|
||||
from amanuensis.server import get_app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -122,3 +124,16 @@ def lexicon_with_editor(make):
|
||||
)
|
||||
assert membership
|
||||
return (lexicon, editor)
|
||||
|
||||
|
||||
class TestConfig(AmanuensisConfig):
|
||||
TESTING = True
|
||||
SECRET_KEY = "secret key"
|
||||
DATABASE_URI = "sqlite:///:memory:"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(db):
|
||||
"""Provides an application running on top of the test database."""
|
||||
server_app = get_app(TestConfig, db)
|
||||
return server_app
|
||||
|
13
tests/test_server.py
Normal file
13
tests/test_server.py
Normal file
@ -0,0 +1,13 @@
|
||||
from flask import Flask
|
||||
|
||||
|
||||
def test_app_testing(app: Flask):
|
||||
"""Confirm that the test config loads correctly."""
|
||||
assert app.testing
|
||||
|
||||
|
||||
def test_client(app: Flask):
|
||||
"""Test that the test client works."""
|
||||
with app.test_client() as client:
|
||||
response = client.get("/")
|
||||
assert b"world" in response.data
|
Loading…
Reference in New Issue
Block a user