Project

General

Profile

« Previous | Next » 

Revision 92fc67cf

Added by koszko over 1 year ago

change store names and data keys to singular

View differences:

background/indexeddb_files_server.js
59 59
    getting.defs_by_res_id.set(id, definition);
60 60

  
61 61
    const file_proms = (definition.scripts || [])
62
	  .map(s => haketilodb.idb_get(getting.tx, "files", s.sha256));
62
	  .map(s => haketilodb.idb_get(getting.tx, "file", s.sha256));
63 63

  
64 64
    const deps_proms = (definition.dependencies || [])
65 65
	  .map(res_ref => get_resource_files(getting, res_ref.identifier));
......
104 104
    const getting = {
105 105
	defs_by_res_id:  new Map(),
106 106
	files_by_res_id: new Map(),
107
	tx:              db.transaction(["files", "resource"])
107
	tx:              db.transaction(["file", "resource"])
108 108
    };
109 109

  
110 110
    let prom_cbs, prom = new Promise((...cbs) => prom_cbs = cbs);
background/patterns_query_manager.js
160 160
    initial_blocking.forEach(b => register("blocking", b));
161 161

  
162 162
    const [setting_tracking, initial_settings] =
163
	  await haketilodb.track.settings(setting_changed);
163
	  await haketilodb.track.setting(setting_changed);
164 164

  
165 165
    for (const setting of initial_settings) {
166 166
	if (setting.name === "default_allow")
common/indexeddb.js
59 59
const version_nr = ver => ver.slice(0, 3).reduce(nr_reductor, [2, 0])[1];
60 60

  
61 61
const stores = 	[
62
    ["files",     {keyPath: "sha256"}],
62
    ["file",      {keyPath: "sha256"}],
63 63
    ["file_uses", {keyPath: "sha256"}],
64 64
    ["resource",  {keyPath: "identifier"}],
65 65
    ["mapping",   {keyPath: "identifier"}],
66
    ["settings",  {keyPath: "name"}],
66
    ["setting",   {keyPath: "name"}],
67 67
    ["blocking",  {keyPath: "pattern"}],
68
    ["repos",     {keyPath: "url"}]
68
    ["repo",      {keyPath: "url"}]
69 69
];
70 70

  
71 71
let db = null;
......
111 111
	store = opened_db.createObjectStore(store_name, key_mode);
112 112

  
113 113
    const ctx = make_context(store.transaction, initial_data.file);
114
    await _save_items(initial_data.resources, initial_data.mappings, ctx);
114
    await _save_items(initial_data.resource, initial_data.mapping, [], ctx);
115 115

  
116 116
    return opened_db;
117 117
}
......
186 186
async function start_items_transaction(item_store_names, files)
187 187
{
188 188
    const db = await get_db();
189
    const scope = [...item_store_names, "files", "file_uses"];
189
    const scope = [...item_store_names, "file", "file_uses"];
190 190
    return make_context(db.transaction(scope, "readwrite"), files);
191 191
}
192 192
#EXPORT start_items_transaction
......
226 226
	if (uses.uses < 1) {
227 227
	    if (!is_new) {
228 228
		idb_del(context.transaction, "file_uses", sha256);
229
		idb_del(context.transaction, "files",     sha256);
229
		idb_del(context.transaction, "file",      sha256);
230 230
	    }
231 231

  
232 232
	    continue;
......
246 246
	    throw "file not present: " + sha256;
247 247
	}
248 248

  
249
	idb_put(context.transaction, "files", {sha256, contents: file});
249
	idb_put(context.transaction, "file", {sha256, contents: file});
250 250
    }
251 251

  
252 252
    return context.result;
......
257 257
 * How a sample data argument to the function below might look like:
258 258
 *
259 259
 * data = {
260
 *     resources: {
260
 *     resource: {
261 261
 *         "resource1": {
262 262
 *             "1": {
263 263
 *                 // some stuff
......
272 272
 *             }
273 273
 *         },
274 274
 *     },
275
 *     mappings: {
275
 *     mapping: {
276 276
 *         "mapping1": {
277 277
 *             "2": {
278 278
 *                 // some stuff
......
295 295
async function save_items(data)
296 296
{
297 297
    const item_store_names = ["resource", "mapping"];
298
    if ("repo" in data)
299
	item_store_names.push("repo");
300

  
298 301
    const context = await start_items_transaction(item_store_names, data.file);
299 302

  
300
    return _save_items(data.resources, data.mappings, context);
303
    return _save_items(data.resource, data.mapping, data.repo || [], context);
301 304
}
302 305
#EXPORT save_items
303 306

  
304
async function _save_items(resources, mappings, context)
307
async function _save_items(resources, mappings, repos, context)
305 308
{
306 309
    resources = Object.values(resources || {}).map(entities.get_newest);
307 310
    mappings  = Object.values(mappings  || {}).map(entities.get_newest);
......
309 312
    for (const item of resources.concat(mappings))
310 313
	await save_item(item, context);
311 314

  
315
    for (const repo_url of repos)
316
	await idb_put(context.transaction, "repo", {url: repo_url});
317

  
312 318
    await finalize_transaction(context);
313 319
}
314 320

  
......
378 384

  
379 385
/*
380 386
 * A simplified kind of transaction for modifying stores without special
381
 * inter-store integrity constraints ("settings", "blocking", "repos").
387
 * inter-store integrity constraints ("setting", "blocking", "repo").
382 388
 */
383 389
async function start_simple_transaction(store_name)
384 390
{
......
386 392
    return make_context(db.transaction(store_name, "readwrite"), {});
387 393
}
388 394

  
389
/* Functions to access the "settings" store. */
395
/* Functions to access the "setting" store. */
390 396
async function set_setting(name, value)
391 397
{
392
    const context = await start_simple_transaction("settings");
393
    broadcast.prepare(context.sender, "idb_changes_settings", name);
394
    await idb_put(context.transaction, "settings", {name, value});
398
    const context = await start_simple_transaction("setting");
399
    broadcast.prepare(context.sender, "idb_changes_setting", name);
400
    await idb_put(context.transaction, "setting", {name, value});
395 401
    return finalize_transaction(context);
396 402
}
397 403
#EXPORT set_setting
398 404

  
399 405
async function get_setting(name)
400 406
{
401
    const transaction = (await get_db()).transaction("settings");
402
    return ((await idb_get(transaction, "settings", name)) || {}).value;
407
    const transaction = (await get_db()).transaction("setting");
408
    return ((await idb_get(transaction, "setting", name)) || {}).value;
403 409
}
404 410
#EXPORT get_setting
405 411

  
......
429 435
}
430 436
#EXPORT get_allowing
431 437

  
432
/* Functions to access the "repos" store. */
438
/* Functions to access the "repo" store. */
433 439
async function set_repo(url, remove=false)
434 440
{
435
    const context = await start_simple_transaction("repos");
436
    broadcast.prepare(context.sender, "idb_changes_repos", url);
441
    const context = await start_simple_transaction("repo");
442
    broadcast.prepare(context.sender, "idb_changes_repo", url);
437 443
    if (remove)
438
	await idb_del(context.transaction, "repos", url);
444
	await idb_del(context.transaction, "repo", url);
439 445
    else
440
	await idb_put(context.transaction, "repos", {url});
446
	await idb_put(context.transaction, "repo", {url});
441 447
    return finalize_transaction(context);
442 448
}
443 449
#EXPORT set_repo
......
445 451
const del_repo = url => set_repo(url, true);
446 452
#EXPORT del_repo
447 453

  
448
const get_repos = () => get_all("repos").then(list => list.map(obj => obj.url));
454
const get_repos = () => get_all("repo").then(list => list.map(obj => obj.url));
449 455
#EXPORT get_repos
450 456

  
451 457
/* Callback used when listening to broadcasts while tracking db changes. */
......
460 466
/*
461 467
 * Monitor changes to `store_name` IndexedDB object store.
462 468
 *
463
 * `store_name` should be either "resource", "mapping", "settings", "blocking"
464
 * or "repos".
469
 * `store_name` should be either "resource", "mapping", "setting", "blocking"
470
 * or "repo".
465 471
 *
466 472
 * `onchange` should be a callback that will be called when an item is added,
467 473
 * modified or removed from the store. The callback will be passed an object
......
492 498
}
493 499

  
494 500
const track = {};
495
const trackable = ["resource", "mapping", "settings", "blocking", "repos"];
501
const trackable = ["resource", "mapping", "setting", "blocking", "repo"];
496 502
for (const store_name of trackable)
497 503
    track[store_name] = onchange => start_tracking(store_name, onchange);
498 504
#EXPORT track
default_settings.json
21 21
// the notice above.
22 22
#ENDIF
23 23
{
24
    "resources": {
24
    "resource": {
25 25
	"haketilo-demo-script": {
26 26
	    "2022.1.28": {
27 27
		"source_name": "haketilo-default-settings",
......
44 44
	    }
45 45
	}
46 46
    },
47
    "mappings": {
47
    "mapping": {
48 48
	"haketilo-demo-message": {
49 49
	    "2022.1.28": {
50 50
		"source_name": "haketilo-default-settings",
......
66 66
	    }
67 67
	}
68 68
    },
69
    "files": {
69
    "file": {
70 70
	"sha256": {
71 71
	    "a2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499": "Creative Commons Legal Code\n\nCC0 1.0 Universal\n\n    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE\n    LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN\n    ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS\n    INFORMATION ON AN \"AS-IS\" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES\n    REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS\n    PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM\n    THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED\n    HEREUNDER.\n\nStatement of Purpose\n\nThe laws of most jurisdictions throughout the world automatically confer\nexclusive Copyright and Related Rights (defined below) upon the creator\nand subsequent owner(s) (each and all, an \"owner\") of an original work of\nauthorship and/or a database (each, a \"Work\").\n\nCertain owners wish to permanently relinquish those rights to a Work for\nthe purpose of contributing to a commons of creative, cultural and\nscientific works (\"Commons\") that the public can reliably and without fear\nof later claims of infringement build upon, modify, incorporate in other\nworks, reuse and redistribute as freely as possible in any form whatsoever\nand for any purposes, including without limitation commercial purposes.\nThese owners may contribute to the Commons to promote the ideal of a free\nculture and the further production of creative, cultural and scientific\nworks, or to gain reputation or greater distribution for their Work in\npart through the use and efforts of others.\n\nFor these and/or other purposes and motivations, and without any\nexpectation of additional consideration or compensation, the person\nassociating CC0 with a Work (the \"Affirmer\"), to the extent that he or she\nis an owner of Copyright and Related Rights in the Work, voluntarily\nelects to apply CC0 to the Work and publicly distribute the Work under its\nterms, with knowledge of his or her Copyright and Related Rights in the\nWork and the meaning and intended legal effect of CC0 on those rights.\n\n1. Copyright and Related Rights. A Work made available under CC0 may be\nprotected by copyright and related or neighboring rights (\"Copyright and\nRelated Rights\"). Copyright and Related Rights include, but are not\nlimited to, the following:\n\n  i. the right to reproduce, adapt, distribute, perform, display,\n     communicate, and translate a Work;\n ii. moral rights retained by the original author(s) and/or performer(s);\niii. publicity and privacy rights pertaining to a person's image or\n     likeness depicted in a Work;\n iv. rights protecting against unfair competition in regards to a Work,\n     subject to the limitations in paragraph 4(a), below;\n  v. rights protecting the extraction, dissemination, use and reuse of data\n     in a Work;\n vi. database rights (such as those arising under Directive 96/9/EC of the\n     European Parliament and of the Council of 11 March 1996 on the legal\n     protection of databases, and under any national implementation\n     thereof, including any amended or successor version of such\n     directive); and\nvii. other similar, equivalent or corresponding rights throughout the\n     world based on applicable law or treaty, and any national\n     implementations thereof.\n\n2. Waiver. To the greatest extent permitted by, but not in contravention\nof, applicable law, Affirmer hereby overtly, fully, permanently,\nirrevocably and unconditionally waives, abandons, and surrenders all of\nAffirmer's Copyright and Related Rights and associated claims and causes\nof action, whether now known or unknown (including existing as well as\nfuture claims and causes of action), in the Work (i) in all territories\nworldwide, (ii) for the maximum duration provided by applicable law or\ntreaty (including future time extensions), (iii) in any current or future\nmedium and for any number of copies, and (iv) for any purpose whatsoever,\nincluding without limitation commercial, advertising or promotional\npurposes (the \"Waiver\"). Affirmer makes the Waiver for the benefit of each\nmember of the public at large and to the detriment of Affirmer's heirs and\nsuccessors, fully intending that such Waiver shall not be subject to\nrevocation, rescission, cancellation, termination, or any other legal or\nequitable action to disrupt the quiet enjoyment of the Work by the public\nas contemplated by Affirmer's express Statement of Purpose.\n\n3. Public License Fallback. Should any part of the Waiver for any reason\nbe judged legally invalid or ineffective under applicable law, then the\nWaiver shall be preserved to the maximum extent permitted taking into\naccount Affirmer's express Statement of Purpose. In addition, to the\nextent the Waiver is so judged Affirmer hereby grants to each affected\nperson a royalty-free, non transferable, non sublicensable, non exclusive,\nirrevocable and unconditional license to exercise Affirmer's Copyright and\nRelated Rights in the Work (i) in all territories worldwide, (ii) for the\nmaximum duration provided by applicable law or treaty (including future\ntime extensions), (iii) in any current or future medium and for any number\nof copies, and (iv) for any purpose whatsoever, including without\nlimitation commercial, advertising or promotional purposes (the\n\"License\"). The License shall be deemed effective as of the date CC0 was\napplied by Affirmer to the Work. Should any part of the License for any\nreason be judged legally invalid or ineffective under applicable law, such\npartial invalidity or ineffectiveness shall not invalidate the remainder\nof the License, and in such case Affirmer hereby affirms that he or she\nwill not (i) exercise any of his or her remaining Copyright and Related\nRights in the Work or (ii) assert any associated claims and causes of\naction with respect to the Work, in either case contrary to Affirmer's\nexpress Statement of Purpose.\n\n4. Limitations and Disclaimers.\n\n a. No trademark or patent rights held by Affirmer are waived, abandoned,\n    surrendered, licensed or otherwise affected by this document.\n b. Affirmer offers the Work as-is and makes no representations or\n    warranties of any kind concerning the Work, express, implied,\n    statutory or otherwise, including without limitation warranties of\n    title, merchantability, fitness for a particular purpose, non\n    infringement, or the absence of latent or other defects, accuracy, or\n    the present or absence of errors, whether or not discoverable, all to\n    the greatest extent permissible under applicable law.\n c. Affirmer disclaims responsibility for clearing rights of other persons\n    that may apply to the Work or any use thereof, including without\n    limitation any person's Copyright and Related Rights in the Work.\n    Further, Affirmer disclaims responsibility for obtaining any necessary\n    consents, permissions or other rights required for any use of the\n    Work.\n d. Affirmer understands and acknowledges that Creative Commons is not a\n    party to this document and has no duty or obligation with respect to\n    this CC0 or use of the Work.\n",
72 72
	    "sha256-f1d9dc9f2f4edaaebd9167eb8b79a6da6434313df47921aa4ea8ae278f7739e3": "/**\n * Haketilo demo script.\n *\n * Copyright (C) 2021 Wojtek Kosior\n * Available under the terms of Creative Commons Zero\n * <https://creativecommons.org/publicdomain/zero/1.0/legalcode>\n */\n\n{\n    const banner = document.createElement(\"h2\");\n    \n    banner.textContent = \"Hoooray! Haketilo works :D\";\n    \n    banner.setAttribute(\"style\", `\\\n    margin: 1em; \\\n    border-radius: 1em 0px; \\\n    background-color: #474; \\\n    padding: 10px 20px; \\\n    color: #eee; \\\n    box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19); \\\n    display: inline-block;\\\n    `);\n    \n    document.body.prepend(banner);\n}\n"
73 73
	}
74
    }
74
    },
75
    "repo": ["https://hydrilla.koszko.org/api_v1"]
75 76
}
html/default_blocking_policy.js
66 66
async function track_default_allow()
67 67
{
68 68
    const set_val = ch => default_allow = (ch.new_val || {}).value;
69
    const [tracking, settings] = await haketilodb.track.settings(update_policy);
69
    const [tracking, settings] = await haketilodb.track.setting(update_policy);
70 70
    for (const setting of settings) {
71 71
	if (setting.name === "default_allow")
72 72
	    default_allow = setting.value;
html/file_preview.js
55 55

  
56 56
async function show_preview(hash_key) {
57 57
    const db = await haketilodb.get();
58
    const file = await haketilodb.idb_get(db.transaction("files"),
59
					  "files", hash_key);
58
    const file = await haketilodb.idb_get(db.transaction("file"),
59
					  "file", hash_key);
60 60
    if (file === undefined) {
61 61
	error("Couldn't find file in Haketilo's internal database :(");
62 62
    } else {
html/install.js
382 382

  
383 383
	if (files !== undefined) {
384 384
	    const data = {file: {sha256: files}};
385
	    const names = [["mappings", "mapping"], ["resources", "resource"]];
386 385

  
387
	    for (const [set_name, type] of names) {
386
	    for (const type of ["resource", "mapping"]) {
388 387
		const set = {};
389 388

  
390 389
		for (const def of item_defs.filter(def => def.type === type))
391 390
		    set[def.identifier] = {[version_string(def.version)]: def};
392 391

  
393
		data[set_name] = set;
392
		data[type] = set;
394 393
	    }
395 394

  
396 395
	    try {
html/text_entry_list.js
311 311
    }
312 312

  
313 313
    dialog.loader(dialog_ctx, "Loading repositories...");
314
    const [tracking, items] = await haketilodb.track.repos(onchange);
314
    const [tracking, items] = await haketilodb.track.repo(onchange);
315 315
    dialog.close(dialog_ctx);
316 316

  
317 317
    list = new TextEntryList(dialog_ctx, () => haketilodb.untrack(tracking),
test/unit/test_indexeddb.py
77 77

  
78 78
    database_contents = get_db_contents(execute_in_page)
79 79

  
80
    assert len(database_contents['files']) == 4
80
    assert len(database_contents['file']) == 4
81 81
    assert all([sample_files_by_sha256[file['sha256']] == file['contents']
82
                for file in database_contents['files']])
83
    assert all([len(file) == 2 for file in database_contents['files']])
82
                for file in database_contents['file']])
83
    assert all([len(file) == 2 for file in database_contents['file']])
84 84

  
85 85
    assert len(database_contents['file_uses']) == 4
86 86
    assert all([uses['uses'] == 1 for uses in database_contents['file_uses']])
87 87
    assert set([uses['sha256'] for uses in database_contents['file_uses']]) \
88
        == set([file['sha256'] for file in database_contents['files']])
88
        == set([file['sha256'] for file in database_contents['file']])
89 89

  
90 90
    assert database_contents['mapping'] == []
91 91
    assert database_contents['resource'] == [sample_item]
......
147 147
                          for file, nr in zip(sample_files_list, uses_list)])
148 148

  
149 149
    files = dict([(file['sha256'], file['contents'])
150
                  for file in database_contents['files']])
150
                  for file in database_contents['file']])
151 151
    assert files == dict([(file['sha256'], file['contents'])
152 152
                          for file in sample_files_list])
153 153

  
......
179 179
    assert uses  == dict([(file['sha256'], 1) for file in sample_files_list])
180 180

  
181 181
    files = dict([(file['sha256'], file['contents'])
182
                  for file in results[0]['files']])
182
                  for file in results[0]['file']])
183 183
    assert files == dict([(file['sha256'], file['contents'])
184 184
                          for file in sample_files_list])
185 185

  
......
192 192
    sample_resource = make_sample_resource()
193 193
    sample_mapping = make_sample_mapping()
194 194
    initial_data = {
195
        'resources': {
195
        'resource': {
196 196
            'helloapple': {
197 197
                '1.12':   sample_resource,
198 198
                '0.9':    'something_that_should_get_ignored',
......
201 201
                '1.11.1': 'something_that_should_get_ignored',
202 202
            }
203 203
        },
204
        'mappings': {
204
        'mapping': {
205 205
            'helloapple': {
206 206
                '0.1.1': sample_mapping
207 207
            }
......
222 222
def test_haketilodb_settings(driver, execute_in_page):
223 223
    """
224 224
    indexeddb.js facilitates operating on Haketilo's internal database.
225
    Verify assigning/retrieving values of simple "settings" item works properly.
225
    Verify assigning/retrieving values of simple "setting" item works properly.
226 226
    """
227 227
    execute_in_page(load_script('common/indexeddb.js'))
228 228
    mock_broadcast(execute_in_page)
......
230 230
    # Start with no database.
231 231
    clear_indexeddb(execute_in_page)
232 232

  
233
    assert get_db_contents(execute_in_page)['settings'] == []
233
    assert get_db_contents(execute_in_page)['setting'] == []
234 234

  
235 235
    assert execute_in_page('returnval(get_setting("option15"));') == None
236 236

  
......
280 280
    # Start with no database.
281 281
    clear_indexeddb(execute_in_page)
282 282

  
283
    assert get_db_contents(execute_in_page)['repos'] == []
283
    assert get_db_contents(execute_in_page)['repo'] == []
284 284

  
285 285
    sample_urls = ['https://hdrlla.example.com/', 'https://hdrlla.example.org']
286 286

  
......
342 342
    sample_resource = make_sample_resource()
343 343
    sample_mapping = make_sample_mapping()
344 344
    initial_data = {
345
        'resources': {
345
        'resource': {
346 346
            'helloapple': {
347 347
                '1.0': sample_resource
348 348
            }
349 349
        },
350
        'mappings': {
350
        'mapping': {
351 351
            'helloapple': {
352 352
                '0.1.1': sample_mapping
353 353
            }
......
404 404
    for elem_id, json_value in [
405 405
            ('resource_helloapple', sample_resource),
406 406
            ('mapping_helloapple', sample_mapping),
407
            ('settings_option15', {'name': 'option15', 'value': '123'}),
408
            ('repos_https://hydril.la', {'url': 'https://hydril.la'}),
407
            ('setting_option15', {'name': 'option15', 'value': '123'}),
408
            ('repo_https://hydril.la', {'url': 'https://hydril.la'}),
409 409
            ('blocking_file:///*', {'pattern': 'file:///*', 'allow': False})
410 410
    ]:
411 411
        assert json.loads(driver.find_element_by_id(elem_id).text) == json_value
......
417 417
    sample_mapping2 = make_sample_mapping()
418 418
    sample_mapping2['identifier'] = 'helloapple-copy'
419 419
    sample_data = {
420
        'resources': {
420
        'resource': {
421 421
            'helloapple-copy': {
422 422
                '1.0': sample_resource2
423 423
            }
424 424
        },
425
        'mappings': {
425
        'mapping': {
426 426
            'helloapple-copy': {
427 427
                '0.1.1': sample_mapping2
428 428
            }
......
441 441
    for elem_id, json_value in [
442 442
            ('resource_helloapple-copy', sample_resource2),
443 443
            ('mapping_helloapple-copy', sample_mapping2),
444
            ('settings_option22', {'name': 'option22', 'value': 'abc'}),
445
            ('repos_https://hydril2.la', {'url': 'https://hydril2.la'}),
444
            ('setting_option22', {'name': 'option22', 'value': 'abc'}),
445
            ('repo_https://hydril2.la', {'url': 'https://hydril2.la'}),
446 446
            ('blocking_ftp://a.bc/', {'pattern': 'ftp://a.bc/', 'allow': True})
447 447
    ]:
448 448
        assert json.loads(driver.find_element_by_id(elem_id).text) == json_value
......
468 468
        }''')
469 469

  
470 470
    removed_ids = ['mapping_helloapple-copy', 'resource_helloapple',
471
                   'repos_https://hydril.la', 'blocking_file:///*']
471
                   'repo_https://hydril.la', 'blocking_file:///*']
472 472
    def condition_items_absent_and_changed(driver):
473 473
        for id in removed_ids:
474 474
            try:
......
477 477
            except WebDriverException:
478 478
                pass
479 479

  
480
        option_text = driver.find_element_by_id('settings_option22').text
480
        option_text = driver.find_element_by_id('setting_option22').text
481 481
        blocking_text = driver.find_element_by_id('blocking_ftp://a.bc/').text
482 482
        return (json.loads(option_text)['value'] == None and
483 483
                json.loads(blocking_text)['allow'] == False)
test/unit/test_indexeddb_files_server.py
51 51
resources = [make_sample_resource_with_deps(n) for n in range(count)]
52 52

  
53 53
sample_data = {
54
    'resources': sample_data_dict(resources),
54
    'resource': sample_data_dict(resources),
55 55
    'mapping': {},
56 56
    'file': {
57 57
        'sha256': sample_files_by_sha256
......
91 91
    function_returned_value = execute_in_page(
92 92
        '''
93 93
        returnval(registered_listener(["???"], {},
94
                  () => location.reload()));
94
                                      () => location.reload()));
95 95
        ''')
96 96
    assert function_returned_value == None
97 97

  
......
138 138
    sample_data_copy = copy.deepcopy(sample_data)
139 139

  
140 140
    if error == 'missing':
141
        del sample_data_copy['resources']['res-3']
141
        del sample_data_copy['resource']['res-3']
142 142
    elif error == 'circular':
143
        res3_defs = sample_data_copy['resources']['res-3'].values()
143
        res3_defs = sample_data_copy['resource']['res-3'].values()
144 144
        next(iter(res3_defs))['dependencies'].append({'identifier': 'res-8'})
145 145

  
146 146
    prepare_test_page(sample_data_copy, execute_in_page)
test/unit/test_install.py
150 150
        assert set([it['identifier'] for it in db_contents[item_type]]) == ids
151 151

  
152 152
    assert all([len(db_contents[store]) == files_count
153
                for store in ('files', 'file_uses')])
153
                for store in ('file', 'file_uses')])
154 154

  
155 155
    # Update the installed mapping to a newer version.
156 156
    execute_in_page('returnval(install_view.show(...arguments));',
test/unit/test_item_list.py
104 104
    items.reverse()
105 105

  
106 106
    sample_data = {
107
        'resources': {},
108
        'mappings': {},
107
        'resource': {},
108
        'mapping': {},
109 109
        'file': {
110 110
            'sha256': sample_files_by_sha256
111 111
        }
......
127 127
                it['long_name'] = f'somewhat renamed {it["long_name"]}'
128 128

  
129 129
        items_to_inclue = [items[i] for i in sorted(to_include)]
130
        sample_data[item_type + 's'] = sample_data_dict(items_to_inclue)
130
        sample_data[item_type] = sample_data_dict(items_to_inclue)
131 131
        execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
132 132
                        sample_data)
133 133

  
134 134
        extra_item['long_name'] = f'{iteration} {extra_item["long_name"]}'
135
        sample_data[item_type + 's'] = sample_data_dict([extra_item])
135
        sample_data[item_type] = sample_data_dict([extra_item])
136 136
        execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
137 137
                        sample_data)
138 138

  
......
189 189
    items = [make_item(item_type, f'item{i}', f'Item {i}') for i in range(3)]
190 190

  
191 191
    sample_data = {
192
        'resources': {},
193
        'mappings': {},
192
        'resource': {},
193
        'mapping': {},
194 194
        'file': {
195 195
            'sha256': sample_files_by_sha256
196 196
        }
197 197
    }
198
    sample_data[item_type + 's'] = sample_data_dict(items)
198
    sample_data[item_type] = sample_data_dict(items)
199 199

  
200 200
    preview_container, dialog_container, ul = execute_in_page(
201 201
        f'''
test/unit/test_item_preview.py
154 154
    execute_in_page(load_script('html/item_preview.js'))
155 155

  
156 156
    sample_data = make_complete_sample_data()
157
    sample_data['mappings'] = {}
157
    sample_data['mapping'] = {}
158 158
    execute_in_page('returnval(haketilodb.save_items(arguments[0]));',
159 159
                    sample_data)
160 160

  
test/unit/test_patterns_query_manager.py
105 105

  
106 106
            return [{}, initial_blocking];
107 107
        }
108
        haketilodb.track.settings = function (cb) {
108
        haketilodb.track.setting = function (cb) {
109 109
            settingchange = cb;
110 110

  
111 111
            return [{}, [{name: "default_allow", value: true}]];
......
271 271
    execute_in_page(load_script('common/indexeddb.js'))
272 272

  
273 273
    sample_data = {
274
        'mappings': dict([(sm['identifier'], {'1.0': sm})
275
                          for sm in sample_mappings]),
276
        'resources': {},
277
        'files': {}
274
        'mapping': dict([(sm['identifier'], {'1.0': sm})
275
                         for sm in sample_mappings]),
276
        'resource': {},
277
        'file': {}
278 278
    }
279 279
    execute_in_page('returnval(save_items(arguments[0]));', sample_data)
280 280

  
test/unit/utils.py
149 149
    be used to populate IndexedDB.
150 150
    """
151 151
    return {
152
        'resources': sample_data_dict([make_sample_resource()]),
153
        'mappings': sample_data_dict([make_sample_mapping()]),
152
        'resource': sample_data_dict([make_sample_resource()]),
153
        'mapping': sample_data_dict([make_sample_mapping()]),
154 154
        'file': {
155 155
            'sha256': sample_files_by_sha256
156 156
        }

Also available in: Unified diff