diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/development_config.json | 5 | ||||
-rw-r--r-- | src/test/test_pydrilla.py | 17 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/test/development_config.json b/src/test/development_config.json index 5998918..30cf10d 100644 --- a/src/test/development_config.json +++ b/src/test/development_config.json @@ -16,6 +16,11 @@ // clients). "static_resource_uri": "http://localhost:8000/", + // Hydrilla will display this link to users as a place where they can + // obtain sources for its software. This config option is meant to ease + // compliance with the AGPL. + "hydrilla_sources_uri": "https://git.koszko.org/pydrilla/", + // Make Pydrilla error out on any warning "werror": true 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/' |