summaryrefslogtreecommitdiff
path: root/test/haketilo_test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/haketilo_test/unit')
-rw-r--r--test/haketilo_test/unit/test_install.py70
-rw-r--r--test/haketilo_test/unit/test_popup.py2
-rw-r--r--test/haketilo_test/unit/test_repo_query.py4
3 files changed, 38 insertions, 38 deletions
diff --git a/test/haketilo_test/unit/test_install.py b/test/haketilo_test/unit/test_install.py
index f4bc483..1e2063c 100644
--- a/test/haketilo_test/unit/test_install.py
+++ b/test/haketilo_test/unit/test_install.py
@@ -70,18 +70,18 @@ def test_install_normal_usage(driver, execute_in_page, complex_variant):
if complex_variant:
# The resource/mapping others depend on.
root_id = 'abcd-defg-ghij'
- root_resource_id = f'resource_{root_id}'
- root_mapping_id = f'mapping_{root_id}'
+ root_resource_id = f'resource-{root_id}'
+ root_mapping_id = f'mapping-{root_id}'
# Those ids are used to check the alphabetical ordering.
- resource_ids = [f'resource_{letters}' for letters in (
+ resource_ids = [f'resource-{letters}' for letters in (
'a', 'abcd', root_id, 'b', 'c',
'd', 'defg', 'e', 'f',
'g', 'ghij', 'h', 'i', 'j'
)]
files_count = 9
else:
- root_resource_id = f'resource_a'
- root_mapping_id = f'mapping_a'
+ root_resource_id = f'resource-a'
+ root_mapping_id = f'mapping-a'
resource_ids = [root_resource_id]
files_count = 0
@@ -102,7 +102,7 @@ def test_install_normal_usage(driver, execute_in_page, complex_variant):
assert not execute_in_page('returnval(ets()[0].old_ver);').is_displayed()
execute_in_page('returnval(ets()[0].details_but);').click()
- assert 'resource_a' in containers['resource_preview_container'].text
+ assert 'resource-a' in containers['resource_preview_container'].text
assert_container_displayed('resource_preview_container')
execute_in_page('returnval(install_view.resource_back_but);').click()
@@ -246,7 +246,7 @@ def test_install_dialogs(driver, execute_in_page, message):
browser.tabs.sendMessage = () => new Promise(cb => {});
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'mapping_a')
+ 'https://hydril.la/', 'mapping', 'mapping-a')
assert dlg_buts() == []
assert dialog_txt() == 'Fetching data from repository...'
@@ -256,7 +256,7 @@ def test_install_dialogs(driver, execute_in_page, message):
browser.tabs.sendMessage = () => Promise.resolve({error: "sth"});
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'mapping_a')
+ 'https://hydril.la/', 'mapping', 'mapping-a')
assert_dlg(['conf_buts'], 'Failure to communicate with repository :(')
elif message == 'HTTP_code_item':
@@ -266,7 +266,7 @@ def test_install_dialogs(driver, execute_in_page, message):
browser.tabs.sendMessage = () => Promise.resolve(response);
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'mapping_a')
+ 'https://hydril.la/', 'mapping', 'mapping-a')
assert_dlg(['conf_buts'], 'Repository sent HTTP code 404 :(')
elif message == 'invalid_JSON':
@@ -276,47 +276,47 @@ def test_install_dialogs(driver, execute_in_page, message):
browser.tabs.sendMessage = () => Promise.resolve(response);
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'mapping_a')
+ 'https://hydril.la/', 'mapping', 'mapping-a')
assert_dlg(['conf_buts'], "Repository's response is not valid JSON :(")
elif message == 'newer_API_version':
execute_in_page(
'''
- const response = {
- ok: true,
- status: 200,
- json: {$schema: "https://hydrilla.koszko.org/schemas/api_mapping_description-2.1.schema.json"}
- };
- browser.tabs.sendMessage = () => Promise.resolve(response);
+ const old_sendMessage = browser.tabs.sendMessage;
+ browser.tabs.sendMessage = async function(...args) {
+ const response = await old_sendMessage(...args);
+ response.json.$schema = "https://hydrilla.koszko.org/schemas/api_mapping_description-255.1.schema.json";
+ return response;
+ }
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'somemapping', [2, 1])
+ 'https://hydril.la/', 'mapping', 'mapping-a', [2022, 5, 10])
assert_dlg(['conf_buts'],
- 'Mapping somemapping-2.1 was served using unsupported Hydrilla API version. You might need to update Haketilo.')
+ 'Mapping mapping-a-2022.5.10 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,
- /* $schema is not a string as it should be. */
- json: {$schema: null}
- };
- browser.tabs.sendMessage = () => Promise.resolve(response);
+ const old_sendMessage = browser.tabs.sendMessage;
+ browser.tabs.sendMessage = async function(...args) {
+ const response = await old_sendMessage(...args);
+ /* identifier is not a string as it should be. */
+ response.json.identifier = 1234567;
+ return response;
+ }
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'resource', 'someresource')
+ 'https://hydril.la/', 'resource', 'resource-a')
assert_dlg(['conf_buts'],
- 'Resource someresource was served using a nonconforming response format.')
+ 'Resource resource-a was served using a nonconforming response format.')
elif message == 'indexeddb_error_item':
execute_in_page(
'''
haketilodb.idb_get = () => {throw "some error";};
install_view.show(...arguments);
''',
- 'https://hydril.la/', 'mapping', 'mapping_a')
+ 'https://hydril.la/', 'mapping', 'mapping-a')
assert_dlg(['conf_buts'],
"Error accessing Haketilo's internal database :(")
@@ -326,7 +326,7 @@ def test_install_dialogs(driver, execute_in_page, message):
haketilodb.save_items = () => new Promise(() => {});
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -343,7 +343,7 @@ def test_install_dialogs(driver, execute_in_page, message):
}
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -355,7 +355,7 @@ def test_install_dialogs(driver, execute_in_page, message):
fetch = () => {throw "some error";};
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -367,7 +367,7 @@ def test_install_dialogs(driver, execute_in_page, message):
fetch = () => Promise.resolve({ok: false, status: 400});
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -379,7 +379,7 @@ def test_install_dialogs(driver, execute_in_page, message):
fetch = () => Promise.resolve({ok: true, status: 200, text: err});
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -396,7 +396,7 @@ def test_install_dialogs(driver, execute_in_page, message):
}
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
@@ -413,7 +413,7 @@ def test_install_dialogs(driver, execute_in_page, message):
haketilodb.save_items = () => {throw "some error";};
returnval(install_view.show(...arguments));
''',
- 'https://hydril.la/', 'mapping', 'mapping_b')
+ 'https://hydril.la/', 'mapping', 'mapping-b')
execute_in_page('returnval(install_view.install_but);').click()
diff --git a/test/haketilo_test/unit/test_popup.py b/test/haketilo_test/unit/test_popup.py
index 1fc262c..e62feb7 100644
--- a/test/haketilo_test/unit/test_popup.py
+++ b/test/haketilo_test/unit/test_popup.py
@@ -224,7 +224,7 @@ def test_popup_repo_query(driver, execute_in_page):
# Click the "Show results" button.
selector = '.repo_query_buttons > button:first-child'
driver.find_element_by_css_selector(selector).click()
- shown = lambda d: 'MAPPING_A' in containers['repo_query'].text
+ shown = lambda d: 'MAPPING-A' in containers['repo_query'].text
WebDriverWait(driver, 10).until(shown)
# Click the "Cancel" button
diff --git a/test/haketilo_test/unit/test_repo_query.py b/test/haketilo_test/unit/test_repo_query.py
index c8c4875..177d415 100644
--- a/test/haketilo_test/unit/test_repo_query.py
+++ b/test/haketilo_test/unit/test_repo_query.py
@@ -99,7 +99,7 @@ def test_repo_query_normal_usage(driver, execute_in_page):
assert len(mapping_entries) == 3
- expected_names = ['MAPPING_ABCD', 'MAPPING_ABCD-DEFG-GHIJ', 'MAPPING_A']
+ expected_names = ['MAPPING-ABCD', 'MAPPING-ABCD-DEFG-GHIJ', 'MAPPING-A']
for name, entry in zip(expected_names, mapping_entries):
assert entry['mapping_name'].text == name
@@ -217,7 +217,7 @@ def test_repo_query_messages(driver, execute_in_page, message):
const response = {
ok: true,
status: 200,
- json: {$schema: "https://hydrilla.koszko.org/schemas/api_query_result-3.2.1.schema.json"}
+ json: {$schema: "https://hydrilla.koszko.org/schemas/api_query_result-255.2.1.schema.json"}
};
browser.tabs.sendMessage = () => Promise.resolve(response);
''')