diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_install.py | 14 | ||||
-rw-r--r-- | test/unit/test_repo_query.py | 30 | ||||
-rw-r--r-- | test/unit/utils.py | 10 | ||||
-rw-r--r-- | test/world_wide_library.py | 13 |
4 files changed, 38 insertions, 29 deletions
diff --git a/test/unit/test_install.py b/test/unit/test_install.py index cef2aa6..f4bc483 100644 --- a/test/unit/test_install.py +++ b/test/unit/test_install.py @@ -197,7 +197,7 @@ def test_install_normal_usage(driver, execute_in_page, complex_variant): 'HTTP_code_item', 'invalid_JSON', 'newer_API_version', - 'invalid_API_version', + 'invalid_response_format', 'indexeddb_error_item', 'installing', 'indexeddb_error_file_uses', @@ -285,7 +285,7 @@ def test_install_dialogs(driver, execute_in_page, message): const response = { ok: true, status: 200, - json: {api_schema_version: [99, 99]} + json: {$schema: "https://hydrilla.koszko.org/schemas/api_mapping_description-2.1.schema.json"} }; browser.tabs.sendMessage = () => Promise.resolve(response); install_view.show(...arguments); @@ -293,15 +293,15 @@ def test_install_dialogs(driver, execute_in_page, message): 'https://hydril.la/', 'mapping', 'somemapping', [2, 1]) assert_dlg(['conf_buts'], - 'Mapping somemapping-2.1 was served using unsupported Hydrilla API version (99.99). You might need to update Haketilo.') - elif message == 'invalid_API_version': + 'Mapping somemapping-2.1 was served using unsupported Hydrilla API version. You might need to update Haketilo.') + elif message == 'invalid_response_format': execute_in_page( ''' const response = { ok: true, status: 200, - /* API version here is not an array as it should be. */ - json: {api_schema_version: 123} + /* $schema is not a string as it should be. */ + json: {$schema: null} }; browser.tabs.sendMessage = () => Promise.resolve(response); install_view.show(...arguments); @@ -309,7 +309,7 @@ def test_install_dialogs(driver, execute_in_page, message): 'https://hydril.la/', 'resource', 'someresource') assert_dlg(['conf_buts'], - 'Resource someresource was served using unsupported Hydrilla API version. You might need to update Haketilo.') + 'Resource someresource was served using a nonconforming response format.') elif message == 'indexeddb_error_item': execute_in_page( ''' diff --git a/test/unit/test_repo_query.py b/test/unit/test_repo_query.py index 77c5e75..c8c4875 100644 --- a/test/unit/test_repo_query.py +++ b/test/unit/test_repo_query.py @@ -137,7 +137,7 @@ def test_repo_query_normal_usage(driver, execute_in_page): 'HTTP_code', 'invalid_JSON', 'newer_API_version', - 'invalid_API_version', + 'invalid_response_format', 'querying_repo', 'no_results' ]) @@ -183,7 +183,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ) show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') done = has_msg('Failure to communicate with repository :(', elem) WebDriverWait(driver, 10).until(done) elif message == 'HTTP_code': @@ -195,7 +195,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ''') show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') done = has_msg('Repository sent HTTP code 405 :(', elem) WebDriverWait(driver, 10).until(done) elif message == 'invalid_JSON': @@ -207,7 +207,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ''') show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') done = has_msg("Repository's response is not valid JSON :(", elem) WebDriverWait(driver, 10).until(done) elif message == 'newer_API_version': @@ -217,30 +217,31 @@ def test_repo_query_messages(driver, execute_in_page, message): const response = { ok: true, status: 200, - json: {api_schema_version: [1234]} + json: {$schema: "https://hydrilla.koszko.org/schemas/api_query_result-3.2.1.schema.json"} }; browser.tabs.sendMessage = () => Promise.resolve(response); ''') show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') - msg = 'Results were served using unsupported Hydrilla API version (1234). You might need to update Haketilo.' + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') + msg = 'Results were served using unsupported Hydrilla API version. You might need to update Haketilo.' WebDriverWait(driver, 10).until(has_msg(msg, elem)) - elif message == 'invalid_API_version': + elif message == 'invalid_response_format': setup_view(execute_in_page, repo_urls) execute_in_page( ''' const response = { ok: true, status: 200, - json: {api_schema_version: null} + /* $schema is not a string as it should be. */ + json: {$schema: null} }; browser.tabs.sendMessage = () => Promise.resolve(response); ''') show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') - msg = 'Results were served using unsupported Hydrilla API version. You might need to update Haketilo.' + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') + msg = 'Results were served using a nonconforming response format.' WebDriverWait(driver, 10).until(has_msg(msg, elem)) elif message == 'querying_repo': setup_view(execute_in_page, repo_urls) @@ -249,7 +250,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ) show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') assert has_msg('Querying repository...', elem)(0) elif message == 'no_results': setup_view(execute_in_page, repo_urls) @@ -259,8 +260,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ok: true, status: 200, json: { - api_schema_version: [1], - api_schema_revision: 1, + $schema: "https://hydrilla.koszko.org/schemas/api_query_result-1.schema.json", mappings: [] } }; @@ -268,7 +268,7 @@ def test_repo_query_messages(driver, execute_in_page, message): ''') show_and_wait_for_repo_entry() - elem = execute_in_page('returnval(view.repo_entries[0].info_span);') + elem = execute_in_page('returnval(view.repo_entries[0].info_div);') WebDriverWait(driver, 10).until(has_msg('No results :(', elem)) else: raise Exception('made a typo in test function params?') diff --git a/test/unit/utils.py b/test/unit/utils.py index 6ff04ed..b27a209 100644 --- a/test/unit/utils.py +++ b/test/unit/utils.py @@ -79,6 +79,11 @@ def make_sample_mapping(with_files=True): Haketilo's IndexedDB. """ return { + '$schema': 'https://hydrilla.koszko.org/schemas/api_mapping_description-1.schema.json', + 'generated_by': { + 'name': 'human', + 'version': 'sapiens-0.8.14' + }, 'source_name': 'example-org-fixes-new', 'source_copyright': [ sample_file_ref('report.spdx'), @@ -106,6 +111,11 @@ def make_sample_resource(with_files=True): Haketilo's IndexedDB. """ return { + '$schema': 'https://hydrilla.koszko.org/schemas/api_resource_description-1.schema.json', + 'generated_by': { + 'name': 'human', + 'version': 'sapiens-0.8.14' + }, 'source_name': 'hello', 'source_copyright': [ sample_file_ref('report.spdx'), diff --git a/test/world_wide_library.py b/test/world_wide_library.py index 56af35f..1e802ab 100644 --- a/test/world_wide_library.py +++ b/test/world_wide_library.py @@ -150,8 +150,6 @@ sample_queries = {} for srt in sample_resource_templates: resource = make_sample_resource() - resource['api_schema_version'] = [1] - resource['api_schema_revision'] = 1 resource['identifier'] = f'resource_{srt["id_suffix"]}' resource['long_name'] = resource['identifier'].upper() resource['uuid'] = str(uuid4()) @@ -166,8 +164,6 @@ for srt in sample_resource_templates: resource_versions[1][-1] += 1 mapping = make_sample_mapping() - mapping['api_schema_version'] = [1] - mapping['api_schema_revision'] = 1 mapping['identifier'] = f'mapping_{srt["id_suffix"]}' mapping['long_name'] = mapping['identifier'].upper() mapping['uuid'] = str(uuid4()) @@ -208,9 +204,12 @@ for srt in sample_resource_templates: def serve_query(command, get_params, post_params): response = { - 'api_schema_version': [1], - 'api_schema_revision': 1, - 'mappings': sample_queries[get_params['url'][0]] + '$schema': 'https://hydrilla.koszko.org/schemas/api_query_result-1.schema.json', + 'generated_by': { + 'name': 'human', + 'version': 'sapiens-0.8.15' + }, + 'mappings': sample_queries[get_params['url'][0]] } return (200, {}, json.dumps(response)) |