aboutsummaryrefslogtreecommitdiff
path: root/test/haketilo_test/world_wide_library.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/haketilo_test/world_wide_library.py')
-rw-r--r--test/haketilo_test/world_wide_library.py39
1 files changed, 32 insertions, 7 deletions
diff --git a/test/haketilo_test/world_wide_library.py b/test/haketilo_test/world_wide_library.py
index 1a90c42..2d227dd 100644
--- a/test/haketilo_test/world_wide_library.py
+++ b/test/haketilo_test/world_wide_library.py
@@ -33,6 +33,8 @@ from shutil import rmtree
from threading import Lock
from uuid import uuid4
import json
+import functools as ft
+import operator as op
from .misc_constants import here
from .unit.utils import * # sample repo data
@@ -114,7 +116,7 @@ sample_contents = [f'Mi povas manĝi vitron, ĝi ne damaĝas min {i}'
for i in range(9)]
sample_hashes = [sha256(c.encode()).digest().hex() for c in sample_contents]
-file_url = lambda hashed: f'https://hydril.la/file/sha256/{hashed}'
+file_url = ft.partial(op.concat, 'https://hydril.la/file/sha256/')
sample_files_catalog = dict([(file_url(h), make_handler(c))
for h, c in zip(sample_hashes, sample_contents)])
@@ -144,18 +146,35 @@ for i in range(10):
'dependencies': []
})
+# The one below will generate items with schema still at version 1, so required
+# mappings will be ignored.
+sample_resource_templates.append({
+ 'id_suffix': 'a-w-required-mapping-v1',
+ 'files_count': 1,
+ 'dependencies': [],
+ 'required_mappings': [{'identifier': 'mapping-a'}]
+})
+
+sample_resource_templates.append({
+ 'id_suffix': 'a-w-required-mapping-v2',
+ 'files_count': 1,
+ 'dependencies': [],
+ 'required_mappings': [{'identifier': 'mapping-a'}],
+ 'schema_ver': '2'
+})
+
sample_resources_catalog = {}
sample_mappings_catalog = {}
sample_queries = {}
for srt in sample_resource_templates:
resource = make_sample_resource()
- resource['identifier'] = f'resource-{srt["id_suffix"]}'
- resource['long_name'] = resource['identifier'].upper()
- resource['uuid'] = str(uuid4())
- resource['dependencies'] = srt['dependencies']
- resource['source_copyright'] = []
- resource['scripts'] = []
+ resource['identifier'] = f'resource-{srt["id_suffix"]}'
+ resource['long_name'] = resource['identifier'].upper()
+ resource['uuid'] = str(uuid4())
+ resource['dependencies'] = srt['dependencies']
+ resource['source_copyright'] = []
+ resource['scripts'] = []
for i in range(srt['files_count']):
file_ref = {'file': f'file_{i}', 'sha256': sample_hashes[i]}
resource[('source_copyright', 'scripts')[i & 1]].append(file_ref)
@@ -191,6 +210,12 @@ for srt in sample_resource_templates:
mapping['payloads'] = payloads
+ for item in resource, mapping:
+ if 'required_mappings' in srt:
+ item['required_mappings'] = srt['required_mappings']
+ if 'schema_ver' in srt:
+ item['$schema'] = item['$schema'].replace('1', srt['schema_ver'])
+
for item, versions, catalog in [
(resource, resource_versions, sample_resources_catalog),
(mapping, mapping_versions, sample_mappings_catalog)