first steps towards testing: added app fixture and first test function
This commit is contained in:
parent
dfe728fdc8
commit
a607b8c4f3
29
tests/conftest.py
Normal file
29
tests/conftest.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import pytest
|
||||||
|
from the_works import create_app
|
||||||
|
|
||||||
|
TEST_DATABASE_URI = "sqlite:///:memory:"
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def app():
|
||||||
|
test_config = {
|
||||||
|
"ENV": "Testing",
|
||||||
|
"SQLALCHEMY_DATABASE_URI": TEST_DATABASE_URI,
|
||||||
|
"TESTING": True
|
||||||
|
}
|
||||||
|
app = create_app(test_config)
|
||||||
|
|
||||||
|
# other setup can go here
|
||||||
|
|
||||||
|
yield app
|
||||||
|
|
||||||
|
# clean up / reset resources here
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def client(app):
|
||||||
|
return app.test_client()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def runner(app):
|
||||||
|
return app.test_cli_runner()
|
||||||
3
tests/unit/test_home.py
Normal file
3
tests/unit/test_home.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
def test_request_home_startpage(client):
|
||||||
|
response = client.get("/")
|
||||||
|
assert response.data.startswith(b"<!DOCTYPE html>\n")
|
||||||
Loading…
Reference in New Issue
Block a user