aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/config.json (renamed from src/test/development_config.json)10
-rw-r--r--src/test/test_server.py26
2 files changed, 20 insertions, 16 deletions
diff --git a/src/test/development_config.json b/src/test/config.json
index c2382f7..a75e2b1 100644
--- a/src/test/development_config.json
+++ b/src/test/config.json
@@ -6,8 +6,8 @@
//
// Available under the terms of Creative Commons Zero v1.0 Universal.
-// this config is meant to be used in development environment;
-// unlike config.json, it shall not be included in distribution
+// this config is meant to be used in development environment; unlike
+// src/hydrilla/server/config.json, it shall not be included in distribution
{
// Relative paths now get resolved from config's containing direcotry.
"malcontent_dir": "./sample_malcontent",
@@ -17,6 +17,12 @@
// compliance with the AGPL.
"hydrilla_project_url": "https://hydrillabugs.koszko.org/projects/hydrilla/wiki",
+ // Port to listen on (not relevant when Flask.test_client() is used).
+ "port": 10112,
+
+ // Use english for HTML files and generated messages.
+ "language": "en_US",
+
// Make Hydrilla error out on any warning
"werror": true
diff --git a/src/test/test_server.py b/src/test/test_server.py
index b3ea741..b283a00 100644
--- a/src/test/test_server.py
+++ b/src/test/test_server.py
@@ -39,10 +39,10 @@ from markupsafe import escape
from hydrilla import util as hydrilla_util
from hydrilla.builder import Build
-from hydrilla.server import create_app
+from hydrilla.server import HydrillaApp, config
here = Path(__file__).resolve().parent
-config_path = here / 'development_config.json'
+config_path = here / 'config.json'
source_path = here / 'source-package-example'
@pytest.fixture(scope="session")
@@ -62,25 +62,23 @@ def default_setup() -> Iterable[dict[str, Path]]:
yield setup
@pytest.fixture(scope="session")
-def client(default_setup: dict[str, Path]) -> Iterable[FlaskClient]:
+def test_config(default_setup) -> Iterable[dict]:
+ """Provide the contents of JSON config file fed to the client."""
+ yield config.load([default_setup['config_path']])
+
+@pytest.fixture(scope="session")
+def client(test_config: dict) -> Iterable[FlaskClient]:
"""Provide app client that serves the object from built sample package."""
- app = create_app(default_setup['config_path'],
- flask_config={'TESTING': True})
+ app = HydrillaApp(test_config, flask_config={'TESTING': True})
with app.test_client() as client:
yield client
-@pytest.fixture(scope="session")
-def development_config(default_setup) -> Iterable[dict]:
- """Provide the contents of JSON config file fed to the client."""
- contents = default_setup['config_path'].read_text()
- yield json.loads(hydrilla_util.strip_json_comments(contents))
-
-def test_project_url(client: FlaskClient, development_config: dict) -> None:
- """Fetch index.html and verify project URL fro config is present there."""
+def test_project_url(client: FlaskClient, test_config: dict) -> None:
+ """Fetch index.html and verify project URL from config is present there."""
response = client.get('/')
assert b'html' in response.data
- project_url = development_config['hydrilla_project_url']
+ project_url = test_config['hydrilla_project_url']
assert escape(project_url).encode() in response.data
@pytest.mark.parametrize('item_type', ['resource', 'mapping'])