Revision 7218849a
Added by koszko over 1 year ago
test/unit/test_indexeddb.py | ||
---|---|---|
78 | 78 |
|
79 | 79 |
execute_in_page( |
80 | 80 |
'''{ |
81 |
const promise = start_items_transaction(["resources"], arguments[1])
|
|
81 |
const promise = start_items_transaction(["resource"], arguments[1]) |
|
82 | 82 |
.then(ctx => save_item(arguments[0], ctx).then(() => ctx)) |
83 | 83 |
.then(finalize_transaction); |
84 | 84 |
returnval(promise); |
... | ... | |
97 | 97 |
assert set([uses['hash_key'] for uses in database_contents['file_uses']]) \ |
98 | 98 |
== set([file['hash_key'] for file in database_contents['files']]) |
99 | 99 |
|
100 |
assert database_contents['mappings'] == []
|
|
101 |
assert database_contents['resources'] == [sample_item]
|
|
100 |
assert database_contents['mapping'] == [] |
|
101 |
assert database_contents['resource'] == [sample_item] |
|
102 | 102 |
|
103 | 103 |
# See if trying to add an item without providing all its files ends in an |
104 | 104 |
# exception and aborts the transaction as it should. |
... | ... | |
111 | 111 |
async function try_add_item() |
112 | 112 |
{ |
113 | 113 |
const context = |
114 |
await start_items_transaction(["resources"], args[1]);
|
|
114 |
await start_items_transaction(["resource"], args[1]); |
|
115 | 115 |
try { |
116 | 116 |
await save_item(args[0], context); |
117 | 117 |
await finalize_transaction(context); |
... | ... | |
137 | 137 |
sample_item = make_sample_mapping() |
138 | 138 |
database_contents = execute_in_page( |
139 | 139 |
'''{ |
140 |
const promise = start_items_transaction(["mappings"], arguments[1])
|
|
140 |
const promise = start_items_transaction(["mapping"], arguments[1]) |
|
141 | 141 |
.then(ctx => save_item(arguments[0], ctx).then(() => ctx)) |
142 | 142 |
.then(finalize_transaction); |
143 | 143 |
returnval(promise); |
... | ... | |
161 | 161 |
assert files == dict([(file['hash_key'], file['contents']) |
162 | 162 |
for file in sample_files_list]) |
163 | 163 |
|
164 |
del database_contents['resources'][0]['source_copyright'][0]['extra_prop']
|
|
165 |
assert database_contents['resources'] == [make_sample_resource()]
|
|
166 |
assert database_contents['mappings'] == [sample_item]
|
|
164 |
del database_contents['resource'][0]['source_copyright'][0]['extra_prop'] |
|
165 |
assert database_contents['resource'] == [make_sample_resource()] |
|
166 |
assert database_contents['mapping'] == [sample_item] |
|
167 | 167 |
|
168 | 168 |
# Try removing the items to get an empty database again. |
169 | 169 |
results = [None, None] |
... | ... | |
172 | 172 |
f'''{{ |
173 | 173 |
const remover = remove_{item_type}; |
174 | 174 |
const promise = |
175 |
start_items_transaction(["{item_type}s"], {{}})
|
|
175 |
start_items_transaction(["{item_type}"], {{}}) |
|
176 | 176 |
.then(ctx => remover('helloapple', ctx).then(() => ctx)) |
177 | 177 |
.then(finalize_transaction); |
178 | 178 |
returnval(promise); |
... | ... | |
193 | 193 |
assert files == dict([(file['hash_key'], file['contents']) |
194 | 194 |
for file in sample_files_list]) |
195 | 195 |
|
196 |
assert results[0]['resources'] == []
|
|
197 |
assert results[0]['mappings'] == [sample_item]
|
|
196 |
assert results[0]['resource'] == [] |
|
197 |
assert results[0]['mapping'] == [sample_item] |
|
198 | 198 |
|
199 | 199 |
assert results[1] == dict([(key, []) for key in results[0].keys()]) |
200 | 200 |
|
... | ... | |
223 | 223 |
execute_in_page('initial_data = arguments[0];', initial_data) |
224 | 224 |
database_contents = get_db_contents(execute_in_page) |
225 | 225 |
|
226 |
assert database_contents['resources'] == [sample_resource]
|
|
227 |
assert database_contents['mappings'] == [sample_mapping]
|
|
226 |
assert database_contents['resource'] == [sample_resource] |
|
227 |
assert database_contents['mapping'] == [sample_mapping] |
|
228 | 228 |
|
229 | 229 |
@pytest.mark.get_page('https://gotmyowndoma.in') |
230 | 230 |
def test_haketilodb_settings(driver, execute_in_page): |
... | ... | |
407 | 407 |
}''') |
408 | 408 |
assert item_counts == [1 for _ in item_counts] |
409 | 409 |
for elem_id, json_value in [ |
410 |
('resources_helloapple', sample_resource),
|
|
411 |
('mappings_helloapple', sample_mapping),
|
|
410 |
('resource_helloapple', sample_resource), |
|
411 |
('mapping_helloapple', sample_mapping), |
|
412 | 412 |
('settings_option15', {'name': 'option15', 'value': '123'}), |
413 | 413 |
('repos_https://hydril.la', {'url': 'https://hydril.la'}), |
414 | 414 |
('blocking_file:///*', {'pattern': 'file:///*', 'allow': False}) |
... | ... | |
442 | 442 |
driver.switch_to.window(windows[0]) |
443 | 443 |
driver.implicitly_wait(10) |
444 | 444 |
for elem_id, json_value in [ |
445 |
('resources_helloapple-copy', sample_resource2),
|
|
446 |
('mappings_helloapple-copy', sample_mapping2),
|
|
445 |
('resource_helloapple-copy', sample_resource2), |
|
446 |
('mapping_helloapple-copy', sample_mapping2), |
|
447 | 447 |
('settings_option22', {'name': 'option22', 'value': 'abc'}), |
448 | 448 |
('repos_https://hydril2.la', {'url': 'https://hydril2.la'}), |
449 | 449 |
('blocking_ftp://a.bc/', {'pattern': 'ftp://a.bc/', 'allow': True}) |
... | ... | |
457 | 457 |
'''{ |
458 | 458 |
async function change_remove_items() |
459 | 459 |
{ |
460 |
const store_names = ["resources", "mappings"];
|
|
460 |
const store_names = ["resource", "mapping"];
|
|
461 | 461 |
const ctx = await start_items_transaction(store_names, {}); |
462 | 462 |
await remove_resource("helloapple", ctx); |
463 | 463 |
await remove_mapping("helloapple-copy", ctx); |
... | ... | |
470 | 470 |
returnval(change_remove_items()); |
471 | 471 |
}''') |
472 | 472 |
|
473 |
removed_ids = ['mappings_helloapple-copy', 'resources_helloapple',
|
|
473 |
removed_ids = ['mapping_helloapple-copy', 'resource_helloapple',
|
|
474 | 474 |
'repos_https://hydril.la', 'blocking_file:///*'] |
475 | 475 |
def condition_items_absent_and_changed(driver): |
476 | 476 |
for id in removed_ids: |
Also available in: Unified diff
add a mapping/resources installation dialog