Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def test_health(client, app): | ||
url_prefix = app.config["API_URL_PREFIX"] | ||
# test that viewing the page renders without template errors | ||
assert client.get(f"/{url_prefix}/api/v1/core/health").status_code == 200 | ||
assert client.get(f"/{url_prefix}/api/v1/core/info").status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
|
||
from app import create_app | ||
from config import Config | ||
|
||
|
||
@pytest.fixture() | ||
def app(): | ||
"""Create and configure a new app instance for each test.""" | ||
# create a temporary file to isolate the database for each test | ||
db_fd, db_path = tempfile.mkstemp() | ||
# create the app with common test config | ||
app = create_app(Config) | ||
|
||
yield app | ||
|
||
# close and remove the temporary database | ||
os.close(db_fd) | ||
os.unlink(db_path) | ||
|
||
|
||
@pytest.fixture() | ||
def client(app): | ||
"""A test client for the app.""" | ||
return app.test_client() | ||
|
||
|
||
@pytest.fixture() | ||
def runner(app): | ||
"""A test runner for the app's Click commands.""" | ||
return app.test_cli_runner() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
|
||
from app import create_app | ||
from config import Config | ||
|
||
|
||
def test_creation(): | ||
conf = Config() | ||
conf.API_URL_PREFIX = "invalid with spaces" | ||
with pytest.raises(ValueError, match="url_prefix"): | ||
create_app(conf) |