summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_indexeddb.py42
-rw-r--r--test/unit/test_indexeddb_files_server.py8
-rw-r--r--test/unit/test_install.py2
-rw-r--r--test/unit/test_item_list.py14
-rw-r--r--test/unit/test_item_preview.py2
-rw-r--r--test/unit/test_patterns_query_manager.py10
-rw-r--r--test/unit/utils.py4
7 files changed, 41 insertions, 41 deletions
diff --git a/test/unit/test_indexeddb.py b/test/unit/test_indexeddb.py
index 9041116..9f31480 100644
--- a/test/unit/test_indexeddb.py
+++ b/test/unit/test_indexeddb.py
@@ -77,15 +77,15 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
database_contents = get_db_contents(execute_in_page)
- assert len(database_contents['files']) == 4
+ assert len(database_contents['file']) == 4
assert all([sample_files_by_sha256[file['sha256']] == file['contents']
- for file in database_contents['files']])
- assert all([len(file) == 2 for file in database_contents['files']])
+ for file in database_contents['file']])
+ assert all([len(file) == 2 for file in database_contents['file']])
assert len(database_contents['file_uses']) == 4
assert all([uses['uses'] == 1 for uses in database_contents['file_uses']])
assert set([uses['sha256'] for uses in database_contents['file_uses']]) \
- == set([file['sha256'] for file in database_contents['files']])
+ == set([file['sha256'] for file in database_contents['file']])
assert database_contents['mapping'] == []
assert database_contents['resource'] == [sample_item]
@@ -147,7 +147,7 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
for file, nr in zip(sample_files_list, uses_list)])
files = dict([(file['sha256'], file['contents'])
- for file in database_contents['files']])
+ for file in database_contents['file']])
assert files == dict([(file['sha256'], file['contents'])
for file in sample_files_list])
@@ -179,7 +179,7 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
assert uses == dict([(file['sha256'], 1) for file in sample_files_list])
files = dict([(file['sha256'], file['contents'])
- for file in results[0]['files']])
+ for file in results[0]['file']])
assert files == dict([(file['sha256'], file['contents'])
for file in sample_files_list])
@@ -192,7 +192,7 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
sample_resource = make_sample_resource()
sample_mapping = make_sample_mapping()
initial_data = {
- 'resources': {
+ 'resource': {
'helloapple': {
'1.12': sample_resource,
'0.9': 'something_that_should_get_ignored',
@@ -201,7 +201,7 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
'1.11.1': 'something_that_should_get_ignored',
}
},
- 'mappings': {
+ 'mapping': {
'helloapple': {
'0.1.1': sample_mapping
}
@@ -222,7 +222,7 @@ def test_haketilodb_item_modifications(driver, execute_in_page):
def test_haketilodb_settings(driver, execute_in_page):
"""
indexeddb.js facilitates operating on Haketilo's internal database.
- Verify assigning/retrieving values of simple "settings" item works properly.
+ Verify assigning/retrieving values of simple "setting" item works properly.
"""
execute_in_page(load_script('common/indexeddb.js'))
mock_broadcast(execute_in_page)
@@ -230,7 +230,7 @@ def test_haketilodb_settings(driver, execute_in_page):
# Start with no database.
clear_indexeddb(execute_in_page)
- assert get_db_contents(execute_in_page)['settings'] == []
+ assert get_db_contents(execute_in_page)['setting'] == []
assert execute_in_page('returnval(get_setting("option15"));') == None
@@ -280,7 +280,7 @@ def test_haketilodb_repos(driver, execute_in_page):
# Start with no database.
clear_indexeddb(execute_in_page)
- assert get_db_contents(execute_in_page)['repos'] == []
+ assert get_db_contents(execute_in_page)['repo'] == []
sample_urls = ['https://hdrlla.example.com/', 'https://hdrlla.example.org']
@@ -342,12 +342,12 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
sample_resource = make_sample_resource()
sample_mapping = make_sample_mapping()
initial_data = {
- 'resources': {
+ 'resource': {
'helloapple': {
'1.0': sample_resource
}
},
- 'mappings': {
+ 'mapping': {
'helloapple': {
'0.1.1': sample_mapping
}
@@ -404,8 +404,8 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
for elem_id, json_value in [
('resource_helloapple', sample_resource),
('mapping_helloapple', sample_mapping),
- ('settings_option15', {'name': 'option15', 'value': '123'}),
- ('repos_https://hydril.la', {'url': 'https://hydril.la'}),
+ ('setting_option15', {'name': 'option15', 'value': '123'}),
+ ('repo_https://hydril.la', {'url': 'https://hydril.la'}),
('blocking_file:///*', {'pattern': 'file:///*', 'allow': False})
]:
assert json.loads(driver.find_element_by_id(elem_id).text) == json_value
@@ -417,12 +417,12 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
sample_mapping2 = make_sample_mapping()
sample_mapping2['identifier'] = 'helloapple-copy'
sample_data = {
- 'resources': {
+ 'resource': {
'helloapple-copy': {
'1.0': sample_resource2
}
},
- 'mappings': {
+ 'mapping': {
'helloapple-copy': {
'0.1.1': sample_mapping2
}
@@ -441,8 +441,8 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
for elem_id, json_value in [
('resource_helloapple-copy', sample_resource2),
('mapping_helloapple-copy', sample_mapping2),
- ('settings_option22', {'name': 'option22', 'value': 'abc'}),
- ('repos_https://hydril2.la', {'url': 'https://hydril2.la'}),
+ ('setting_option22', {'name': 'option22', 'value': 'abc'}),
+ ('repo_https://hydril2.la', {'url': 'https://hydril2.la'}),
('blocking_ftp://a.bc/', {'pattern': 'ftp://a.bc/', 'allow': True})
]:
assert json.loads(driver.find_element_by_id(elem_id).text) == json_value
@@ -468,7 +468,7 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
}''')
removed_ids = ['mapping_helloapple-copy', 'resource_helloapple',
- 'repos_https://hydril.la', 'blocking_file:///*']
+ 'repo_https://hydril.la', 'blocking_file:///*']
def condition_items_absent_and_changed(driver):
for id in removed_ids:
try:
@@ -477,7 +477,7 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text):
except WebDriverException:
pass
- option_text = driver.find_element_by_id('settings_option22').text
+ option_text = driver.find_element_by_id('setting_option22').text
blocking_text = driver.find_element_by_id('blocking_ftp://a.bc/').text
return (json.loads(option_text)['value'] == None and
json.loads(blocking_text)['allow'] == False)
diff --git a/test/unit/test_indexeddb_files_server.py b/test/unit/test_indexeddb_files_server.py
index d320eba..6ddfba8 100644
--- a/test/unit/test_indexeddb_files_server.py
+++ b/test/unit/test_indexeddb_files_server.py
@@ -51,7 +51,7 @@ def make_sample_resource_with_deps(n):
resources = [make_sample_resource_with_deps(n) for n in range(count)]
sample_data = {
- 'resources': sample_data_dict(resources),
+ 'resource': sample_data_dict(resources),
'mapping': {},
'file': {
'sha256': sample_files_by_sha256
@@ -91,7 +91,7 @@ def test_indexeddb_files_server_normal_usage(driver, execute_in_page):
function_returned_value = execute_in_page(
'''
returnval(registered_listener(["???"], {},
- () => location.reload()));
+ () => location.reload()));
''')
assert function_returned_value == None
@@ -138,9 +138,9 @@ def test_indexeddb_files_server_errors(driver, execute_in_page, error):
sample_data_copy = copy.deepcopy(sample_data)
if error == 'missing':
- del sample_data_copy['resources']['res-3']
+ del sample_data_copy['resource']['res-3']
elif error == 'circular':
- res3_defs = sample_data_copy['resources']['res-3'].values()
+ res3_defs = sample_data_copy['resource']['res-3'].values()
next(iter(res3_defs))['dependencies'].append({'identifier': 'res-8'})
prepare_test_page(sample_data_copy, execute_in_page)
diff --git a/test/unit/test_install.py b/test/unit/test_install.py
index 303d31a..cef2aa6 100644
--- a/test/unit/test_install.py
+++ b/test/unit/test_install.py
@@ -150,7 +150,7 @@ def test_install_normal_usage(driver, execute_in_page, complex_variant):
assert set([it['identifier'] for it in db_contents[item_type]]) == ids
assert all([len(db_contents[store]) == files_count
- for store in ('files', 'file_uses')])
+ for store in ('file', 'file_uses')])
# Update the installed mapping to a newer version.
execute_in_page('returnval(install_view.show(...arguments));',
diff --git a/test/unit/test_item_list.py b/test/unit/test_item_list.py
index 189646e..35ed1d5 100644
--- a/test/unit/test_item_list.py
+++ b/test/unit/test_item_list.py
@@ -104,8 +104,8 @@ def test_item_list_ordering(driver, execute_in_page, item_type):
items.reverse()
sample_data = {
- 'resources': {},
- 'mappings': {},
+ 'resource': {},
+ 'mapping': {},
'file': {
'sha256': sample_files_by_sha256
}
@@ -127,12 +127,12 @@ def test_item_list_ordering(driver, execute_in_page, item_type):
it['long_name'] = f'somewhat renamed {it["long_name"]}'
items_to_inclue = [items[i] for i in sorted(to_include)]
- sample_data[item_type + 's'] = sample_data_dict(items_to_inclue)
+ sample_data[item_type] = sample_data_dict(items_to_inclue)
execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
sample_data)
extra_item['long_name'] = f'{iteration} {extra_item["long_name"]}'
- sample_data[item_type + 's'] = sample_data_dict([extra_item])
+ sample_data[item_type] = sample_data_dict([extra_item])
execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
sample_data)
@@ -189,13 +189,13 @@ def test_item_list_displaying(driver, execute_in_page, item_type):
items = [make_item(item_type, f'item{i}', f'Item {i}') for i in range(3)]
sample_data = {
- 'resources': {},
- 'mappings': {},
+ 'resource': {},
+ 'mapping': {},
'file': {
'sha256': sample_files_by_sha256
}
}
- sample_data[item_type + 's'] = sample_data_dict(items)
+ sample_data[item_type] = sample_data_dict(items)
preview_container, dialog_container, ul = execute_in_page(
f'''
diff --git a/test/unit/test_item_preview.py b/test/unit/test_item_preview.py
index c715d75..fe9a98e 100644
--- a/test/unit/test_item_preview.py
+++ b/test/unit/test_item_preview.py
@@ -154,7 +154,7 @@ def test_file_preview_link(driver, execute_in_page):
execute_in_page(load_script('html/item_preview.js'))
sample_data = make_complete_sample_data()
- sample_data['mappings'] = {}
+ sample_data['mapping'] = {}
execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
sample_data)
diff --git a/test/unit/test_patterns_query_manager.py b/test/unit/test_patterns_query_manager.py
index 13d0add..9fbc438 100644
--- a/test/unit/test_patterns_query_manager.py
+++ b/test/unit/test_patterns_query_manager.py
@@ -105,7 +105,7 @@ def test_pqm_tree_building(driver, execute_in_page):
return [{}, initial_blocking];
}
- haketilodb.track.settings = function (cb) {
+ haketilodb.track.setting = function (cb) {
settingchange = cb;
return [{}, [{name: "default_allow", value: true}]];
@@ -271,10 +271,10 @@ def test_pqm_script_injection(driver, execute_in_page):
execute_in_page(load_script('common/indexeddb.js'))
sample_data = {
- 'mappings': dict([(sm['identifier'], {'1.0': sm})
- for sm in sample_mappings]),
- 'resources': {},
- 'files': {}
+ 'mapping': dict([(sm['identifier'], {'1.0': sm})
+ for sm in sample_mappings]),
+ 'resource': {},
+ 'file': {}
}
execute_in_page('returnval(save_items(arguments[0]));', sample_data)
diff --git a/test/unit/utils.py b/test/unit/utils.py
index 04a4d97..6ff04ed 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -149,8 +149,8 @@ def make_complete_sample_data():
be used to populate IndexedDB.
"""
return {
- 'resources': sample_data_dict([make_sample_resource()]),
- 'mappings': sample_data_dict([make_sample_mapping()]),
+ 'resource': sample_data_dict([make_sample_resource()]),
+ 'mapping': sample_data_dict([make_sample_mapping()]),
'file': {
'sha256': sample_files_by_sha256
}