Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9343988
D4714.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D4714.diff
View Options
diff --git a/swh/deposit/api/checks.py b/swh/deposit/api/checks.py
--- a/swh/deposit/api/checks.py
+++ b/swh/deposit/api/checks.py
@@ -35,10 +35,9 @@
for field, value in metadata.items():
for possible_names in alternate_fields:
- for possible_name in possible_names:
- if possible_name in field:
- alternate_fields[possible_names] = True
- continue
+ if field in possible_names:
+ alternate_fields[possible_names] = True
+ continue
mandatory_result = [" or ".join(k) for k, v in alternate_fields.items() if not v]
diff --git a/swh/deposit/tests/api/test_checks.py b/swh/deposit/tests/api/test_checks.py
--- a/swh/deposit/tests/api/test_checks.py
+++ b/swh/deposit/tests/api/test_checks.py
@@ -81,6 +81,18 @@
"fields": ["atom:author or codemeta:author"],
},
),
+ (
+ {
+ "atom:url": "something",
+ "atom:external_identifier": "something-else",
+ "atom:title": "foobar",
+ "atom:authorblahblah": "foo",
+ },
+ {
+ "summary": "Mandatory fields are missing",
+ "fields": ["atom:author or codemeta:author"],
+ },
+ ),
],
)
def test_api_checks_check_metadata_ko(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 2:01 PM (2 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220784
Attached To
D4714: Use string equality instead of substring search to check for mandatory fields.
Event Timeline
Log In to Comment