aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-02-18 16:36:11 +0100
committerWojtek Kosior <koszko@koszko.org>2022-02-18 16:36:11 +0100
commit5aef54c8086ea2d51407ace02ccd9b35cd69cb09 (patch)
treea89232551f0f66d21f2462b47089d061cd36e86c
parentee0a4a935a95a9472655f85a04e1323f3d328898 (diff)
downloadbrowser-extension-5aef54c8086ea2d51407ace02ccd9b35cd69cb09.tar.gz
browser-extension-5aef54c8086ea2d51407ace02ccd9b35cd69cb09.zip
make "uuid" an optional property
-rw-r--r--html/item_preview.js4
-rw-r--r--test/haketilo_test/unit/test_item_preview.py19
2 files changed, 15 insertions, 8 deletions
diff --git a/html/item_preview.js b/html/item_preview.js
index b67455a..cdc56d9 100644
--- a/html/item_preview.js
+++ b/html/item_preview.js
@@ -81,7 +81,7 @@ function resource_preview(resource, preview_object, link_cb=make_file_link) {
preview_object.identifier.innerText = resource.identifier;
preview_object.long_name.innerText = resource.long_name;
- preview_object.uuid.innerText = resource.uuid;
+ preview_object.uuid.innerText = resource.uuid || "not set";
preview_object.version.innerText =
`${resource.version.join(".")}-${resource.revision}`;
preview_object.description.innerText = resource.description;
@@ -118,7 +118,7 @@ function mapping_preview(mapping, preview_object, link_cb=make_file_link) {
preview_object.identifier.innerText = mapping.identifier;
preview_object.long_name.innerText = mapping.long_name;
- preview_object.uuid.innerText = mapping.uuid;
+ preview_object.uuid.innerText = mapping.uuid || "not set";
preview_object.version.innerText = mapping.version.join(".");
preview_object.description.innerText = mapping.description;
preview_object.source_name.innerText = mapping.source_name;
diff --git a/test/haketilo_test/unit/test_item_preview.py b/test/haketilo_test/unit/test_item_preview.py
index fe9a98e..5faa598 100644
--- a/test/haketilo_test/unit/test_item_preview.py
+++ b/test/haketilo_test/unit/test_item_preview.py
@@ -37,6 +37,7 @@ def test_resource_preview(driver, execute_in_page):
execute_in_page(load_script('html/item_preview.js'))
sample_resource = make_sample_resource()
+ uuid = sample_resource['uuid']
preview_div = execute_in_page(
'''
@@ -48,16 +49,18 @@ def test_resource_preview(driver, execute_in_page):
text = preview_div.text
assert '...' not in text
+ assert 'not set' not in text
for string in [
*filter(lambda v: type(v) is str, sample_resource.values()),
*[rr['identifier'] for rr in sample_resource['dependencies']],
*[c['file'] for k in ('source_copyright', 'scripts')
for c in sample_resource[k]],
- item_version_string(sample_resource, True)
+ item_version_string(sample_resource, True), uuid
]:
assert string in text
+ del sample_resource['uuid']
sample_resource['identifier'] = 'hellopear'
sample_resource['long_name'] = 'Hello Pear'
sample_resource['description'] = 'greets a pear'
@@ -73,12 +76,13 @@ def test_resource_preview(driver, execute_in_page):
sample_resource)
text = preview_div.text
- for string in ['...', 'pple', 'hello-message', 'report.spdx',
+ for string in [uuid, '...', 'pple', 'hello-message', 'report.spdx',
'LICENSES/CC0-1.0.txt', 'hello.js', 'bye.js']:
assert string not in text
for string in ['hellopear', 'Hello Pear', 'hello-msg', 'greets a pear',
- 'report_spdx', 'LICENSES/CC0-1_0_txt', 'hello_js', 'bye_js']:
+ 'report_spdx', 'LICENSES/CC0-1_0_txt', 'hello_js', 'bye_js',
+ 'not set']:
assert string in text
@pytest.mark.ext_data({
@@ -93,6 +97,7 @@ def test_mapping_preview(driver, execute_in_page):
execute_in_page(load_script('html/item_preview.js'))
sample_mapping = make_sample_mapping()
+ uuid = sample_mapping['uuid']
preview_div = execute_in_page(
'''
@@ -104,15 +109,17 @@ def test_mapping_preview(driver, execute_in_page):
text = preview_div.text
assert '...' not in text
+ assert 'not set' not in text
for string in [
*filter(lambda v: type(v) is str, sample_mapping.values()),
*[p['identifier'] for p in sample_mapping['payloads'].values()],
*[c['file'] for c in sample_mapping['source_copyright']],
- item_version_string(sample_mapping)
+ item_version_string(sample_mapping), uuid
]:
assert string in text
+ del sample_mapping['uuid']
sample_mapping['identifier'] = 'example-org-bloated'
sample_mapping['long_name'] = 'Example.org Bloated',
sample_mapping['payloads'] = dict(
@@ -129,12 +136,12 @@ def test_mapping_preview(driver, execute_in_page):
sample_mapping)
text = preview_div.text
- for string in ['...', 'inimal', 'example.org', 'report.spdx',
+ for string in [uuid, '...', 'inimal', 'example.org', 'report.spdx',
'LICENSES/CC0-1.0.txt']:
assert string not in text
for string in ['example-org-bloated', 'Example.org Bloated', 'example.com',
- 'report_spdx', 'LICENSES/CC0-1_0_txt']:
+ 'report_spdx', 'LICENSES/CC0-1_0_txt', 'not set']:
assert string in text
@pytest.mark.ext_data({