summaryrefslogtreecommitdiff
path: root/test/unit/utils.py
diff options
context:
space:
mode:
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])