diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-11-15 18:49:42 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-11-15 18:49:42 +0100 |
commit | 10ce5c83b94714b12061b5befe1157ce72ade3c1 (patch) | |
tree | 4f5b520c8ee28619cec7a2438a28e174affb74e1 /src/test | |
parent | 214f4d2183bc633c8130d7d358a0dbbdc92fafe6 (diff) | |
download | haketilo-hydrilla-10ce5c83b94714b12061b5befe1157ce72ade3c1.tar.gz haketilo-hydrilla-10ce5c83b94714b12061b5befe1157ce72ade3c1.zip |
make test pass
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_pydrilla.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/test/test_pydrilla.py b/src/test/test_pydrilla.py index 5937db9..07c580a 100644 --- a/src/test/test_pydrilla.py +++ b/src/test/test_pydrilla.py @@ -31,23 +31,36 @@ from pathlib import Path from os import mkdir, unlink, environ import json -import pydrilla +from pydrilla import pydrilla, create_app test_dir = Path(__file__).resolve().parent -pydrilla_dir = Path(hydrilla.__file__).resolve().parent -test_config_path = test_dir / 'config.json' +pydrilla_dir = Path(pydrilla.__file__).resolve().parent +test_config_path = pydrilla_dir / 'development_config.json' @pytest.fixture def client(): - app = pydrilla.create_app(test_config_path, flask_config={'TESTING': True}) + app = create_app(test_config_path, flask_config={'TESTING': True}) with app.test_client() as client: yield client -def test_basic(client): +def test_api_basic(client): response = client.get('/') assert b'html' in response.data + for item_type in ['mapping', 'resource']: + response = client.get(f'/{item_type}s/helloapple') + definition = json.loads(response.data.decode()) + assert definition['type'] == item_type + assert definition['source_name'] == 'hello' + assert definition['version'] == [2021, 11, 10] + + response = client.get(f'/{item_type}s/helloapple?ver=2021.11.10.0') + assert definition == json.loads(response.data.decode()) + + response = client.get(f'/{item_type}s/helloapple?ver=2021.11.10.999') + assert response.status_code == 404 + 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] |