From b590eaa2f64ead3384eadc6fe58f6358aa1a0478 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 22 Dec 2021 16:39:34 +0100 Subject: reworked build system; added missing license notices --- test/unit/test_indexeddb.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'test/unit/test_indexeddb.py') diff --git a/test/unit/test_indexeddb.py b/test/unit/test_indexeddb.py index 3604ee9..af60e1c 100644 --- a/test/unit/test_indexeddb.py +++ b/test/unit/test_indexeddb.py @@ -27,8 +27,8 @@ from selenium.common.exceptions import WebDriverException from ..script_loader import load_script -def indexeddb_js(): - return load_script('common/indexeddb.js', ['common']) +indexeddb_js = lambda: load_script('common/indexeddb.js') +broker_js = lambda: load_script('background/broadcast_broker.js') + ';start();' def sample_file(contents): return { @@ -118,7 +118,7 @@ def test_haketilodb_save_remove(execute_in_page): ''' async function get_database_contents() { - const db = await haketilodb.get(); + const db = await get_db(); const transaction = db.transaction(db.objectStoreNames); const store_names_reqs = [...db.objectStoreNames] @@ -226,7 +226,7 @@ def test_haketilodb_save_remove(execute_in_page): for i, item_type in enumerate(['resource', 'mapping']): results[i] = execute_in_page( f'''{{ - const remover = haketilodb.remove_{item_type}; + const remover = remove_{item_type}; const promise = start_items_transaction(["{item_type}s"], {{}}) .then(ctx => remover('helloapple', ctx).then(() => ctx)) @@ -282,10 +282,6 @@ def test_haketilodb_save_remove(execute_in_page): assert database_contents['resources'] == [sample_resource] assert database_contents['mappings'] == [sample_mapping] -def broker_js(): - js = load_script('background/broadcast_broker.js', ['common', 'background']) - return js + ';start_broadcast_broker();' - test_page_html = ''' @@ -336,8 +332,7 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text): driver.switch_to.window(window) execute_in_page('initial_data = arguments[0];', initial_data) - # See if haketilodb.track_*() functions properly return the already-existing - # items. + # See if track_*() functions properly return the already-existing items. execute_in_page( ''' function update_item(store_name, change) @@ -361,9 +356,9 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text): const update_mapping = change => update_item("mappings", change); [resource_tracking, resource_items] = - await haketilodb.track_resources(update_resource); + await track_resources(update_resource); [mapping_tracking, mapping_items] = - await haketilodb.track_mappings(update_mapping); + await track_mappings(update_mapping); for (const item of resource_items) update_resource({identifier: item.identifier, new_val: item}); @@ -404,8 +399,7 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text): }, 'files': sample_files_by_hash } - execute_in_page('returnval(haketilodb.save_items(arguments[0]));', - sample_data) + execute_in_page('returnval(save_items(arguments[0]));', sample_data) driver.switch_to.window(windows[0]) driver.implicitly_wait(10) @@ -421,11 +415,11 @@ def test_haketilodb_track(driver, execute_in_page, wait_elem_text): '''{ async function remove_items() { - const store_names = ["resources", "mappings"]; - const ctx = await haketilodb.start_items_transaction(store_names, {}); - await haketilodb.remove_resource("helloapple", ctx); - await haketilodb.remove_mapping("helloapple-copy", ctx); - await haketilodb.finalize_items_transaction(ctx); + const store_names = ["resources", "mappings"]; + const ctx = await start_items_transaction(store_names, {}); + await remove_resource("helloapple", ctx); + await remove_mapping("helloapple-copy", ctx); + await finalize_items_transaction(ctx); } returnval(remove_items()); }''') -- cgit v1.2.3