summaryrefslogtreecommitdiff
path: root/test/unit/utils.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-01-08 19:23:17 +0100
committerWojtek Kosior <koszko@koszko.org>2022-01-08 19:23:17 +0100
commit38650a8102fe0841617cd80f3a6e45b1f5f62fd5 (patch)
treede1916787c83ec317b51f0dcfc9c95f42ae23e5c /test/unit/utils.py
parent448820a11634de6ec356c77b8c7c0cf4937b344c (diff)
downloadbrowser-extension-38650a8102fe0841617cd80f3a6e45b1f5f62fd5.tar.gz
browser-extension-38650a8102fe0841617cd80f3a6e45b1f5f62fd5.zip
further item list work
There is now a mechanism for removing an item and there are more tests for item list. The entire thing is still work in progress.
Diffstat (limited to 'test/unit/utils.py')
-rw-r--r--test/unit/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/unit/utils.py b/test/unit/utils.py
index e2d89b9..b6b389f 100644
--- a/test/unit/utils.py
+++ b/test/unit/utils.py
@@ -57,3 +57,12 @@ def item_version_string(definition, include_revision=False):
ver = '.'.join([str(num) for num in definition['version']])
revision = definition.get('revision') if include_revision else None
return f'{ver}-{revision}' if revision is not None else ver
+
+def sample_data_dict(items):
+ """
+ Some indexeddb functions expect saved items to be provided in a nested dict
+ that makes them queryable by identifier by version. This function converts
+ items list to such dict.
+ """
+ return dict([(it['identifier'], {item_version_string(it): it})
+ for it in items])