diff options
author | Wojtek Kosior <koszko@koszko.org> | 2021-11-18 20:50:11 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2021-11-18 20:50:11 +0100 |
commit | 5200c39fca2d870b07c18b395619937b54d9d116 (patch) | |
tree | a2d227150729a765059a3ce0ffdb0766c4ad6211 /src/test | |
parent | a6721b316fca0f7a460fa2e62ed679238f97a10e (diff) | |
download | haketilo-hydrilla-5200c39fca2d870b07c18b395619937b54d9d116.tar.gz haketilo-hydrilla-5200c39fca2d870b07c18b395619937b54d9d116.zip |
implement redirections to resources
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_pydrilla.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test_pydrilla.py b/src/test/test_pydrilla.py index db9a321..22022ae 100644 --- a/src/test/test_pydrilla.py +++ b/src/test/test_pydrilla.py @@ -58,12 +58,14 @@ def test_api_basic(client, development_config): for item_type in ['mapping', 'resource']: response = client.get(f'/{item_type}s/helloapple') + assert response.status_code == 200 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 response.status_code == 200 assert definition == json.loads(response.data.decode()) response = client.get(f'/{item_type}s/helloapple?ver=2021.11.10.999') @@ -76,12 +78,14 @@ def test_api_basic(client, development_config): assert response.status_code == 404 response = client.get(f'/{item_type}s/helloapple?ver=all') + assert response.status_code == 200 definitions = json.loads(response.data.decode()) assert type(definitions) is list assert all([d['type'] == item_type for d in definitions]) assert any([d['version'] == [2021, 11, 10] for d in definitions]) response = client.get('/licenses/CC0-1.0') + assert response.status_code == 200 definition = json.loads(response.data.decode()) assert definition['type'] == 'license' assert definition['long_name'] == 'Creative Commons Zero v1.0 Universal' @@ -91,6 +95,7 @@ def test_api_basic(client, development_config): assert response.status_code == 404 response = client.get('/sources/hello') + assert response.status_code == 200 definition = json.loads(response.data.decode()) assert definition['source_name'] == 'hello' @@ -100,6 +105,7 @@ def test_api_basic(client, development_config): assert response.status_code == 404 response = client.get('/query?url=https://hachettebugs.koszko.org') + assert response.status_code == 200 definitions = json.loads(response.data.decode()) assert type(definitions) is list assert all([d['type'] == 'mapping' for d in definitions]) @@ -107,9 +113,20 @@ def test_api_basic(client, development_config): for d in definitions for p in d['payloads']]) response = client.get('/query?url=https://random_bad_domain.org/something') + assert response.status_code == 200 definitions = json.loads(response.data.decode()) assert definitions == [] + resource_uri = development_config['static_resource_uri'] + response = client.get('/sources/hello/hello.js') + assert response.status_code == 301 + assert response.location == resource_uri + 'hello/hello.js' + response = client.get('/sources/random-bad-identifier/hello.js') + assert response.status_code == 404 + response = client.get('/sources/hello/random/bad/path') + assert response.status_code == 301 + assert response.location == resource_uri + 'hello/random/bad/path' + 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] |