summaryrefslogtreecommitdiff
path: root/src/test/test_pydrilla.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_pydrilla.py')
-rw-r--r--src/test/test_pydrilla.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/test/test_pydrilla.py b/src/test/test_pydrilla.py
index 9ec6ba6..660c8f3 100644
--- a/src/test/test_pydrilla.py
+++ b/src/test/test_pydrilla.py
@@ -30,23 +30,31 @@ import shutil
from pathlib import Path
from os import mkdir, unlink, environ
import json
+from markupsafe import escape
from pydrilla import pydrilla, create_app
test_dir = Path(__file__).resolve().parent
packages_dir = test_dir.parent
-test_config_path = test_dir / 'development_config.json'
+development_config_path = test_dir / 'development_config.json'
@pytest.fixture
def client():
- app = create_app(test_config_path, flask_config={'TESTING': True})
+ app = create_app(development_config_path, flask_config={'TESTING': True})
with app.test_client() as client:
yield client
-def test_api_basic(client):
+@pytest.fixture
+def development_config():
+ with open(development_config_path) as config_file:
+ yield json.loads(pydrilla.strip_json_comments(config_file.read()))
+
+def test_api_basic(client, development_config):
response = client.get('/')
assert b'html' in response.data
+ sources_uri = development_config['hydrilla_sources_uri']
+ assert escape(sources_uri).encode() in response.data
for item_type in ['mapping', 'resource']:
response = client.get(f'/{item_type}s/helloapple')
@@ -95,3 +103,6 @@ def test_normalize_version():
assert pydrilla.normalize_version([4, 5, 3, 0, 0]) == [4, 5, 3]
assert pydrilla.normalize_version([1, 0, 5, 0]) == [1, 0, 5]
assert pydrilla.normalize_version([3, 3]) == [3, 3]
+
+def test_strip_json_comments(development_config):
+ assert development_config['static_resource_uri'] == 'http://localhost:8000/'