diff --git a/swh/web/tests/api/views/test_origin.py b/swh/web/tests/api/views/test_origin.py --- a/swh/web/tests/api/views/test_origin.py +++ b/swh/web/tests/api/views/test_origin.py @@ -579,23 +579,27 @@ "api-1-origin-metadata-search", query_params={"fulltext": ORIGIN_METADATA_VALUE} ) rv = check_api_get_responses(api_client, url, status_code=200) - - expected_data = [ - { - "url": origin_url, - "metadata": { - "from_revision": master_rev, - "tool": { - "name": INDEXER_TOOL["tool_name"], - "version": INDEXER_TOOL["tool_version"], - "configuration": INDEXER_TOOL["tool_configuration"], - "id": INDEXER_TOOL["id"], + rv.data = sorted(rv.data, key=lambda d: d["url"]) + + expected_data = sorted( + [ + { + "url": origin_url, + "metadata": { + "from_revision": ORIGIN_MASTER_REVISION[origin_url], + "tool": { + "name": INDEXER_TOOL["tool_name"], + "version": INDEXER_TOOL["tool_version"], + "configuration": INDEXER_TOOL["tool_configuration"], + "id": INDEXER_TOOL["id"], + }, + "mappings": [], }, - "mappings": [], - }, - } - for origin_url, master_rev in ORIGIN_MASTER_REVISION.items() - ] + } + for origin_url in sorted(ORIGIN_MASTER_REVISION.keys()) + ], + key=lambda d: d["url"], + ) for i in range(len(expected_data)): expected = expected_data[i] @@ -605,6 +609,7 @@ assert any( [ORIGIN_METADATA_VALUE in json.dumps(val) for val in metadata.values()] ) + assert response == expected @@ -655,8 +660,8 @@ ) rv = check_api_get_responses(api_client, url, status_code=200) - expected_data = {ORIGIN_METADATA_KEY: ORIGIN_METADATA_VALUE} - assert rv.data == expected_data + assert ORIGIN_METADATA_KEY in rv.data + assert rv.data[ORIGIN_METADATA_KEY] == ORIGIN_METADATA_VALUE def test_api_origin_metadata_search_invalid(api_client, mocker): diff --git a/swh/web/tests/data.py b/swh/web/tests/data.py --- a/swh/web/tests/data.py +++ b/swh/web/tests/data.py @@ -121,6 +121,12 @@ "type": "git", "url": "https://github.com/memononen/libtess2", "archives": ["libtess2.zip"], + "metadata": { + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "description": ( + "Game and tools oriented refactored version of GLU tessellator." + ), + }, }, { "type": "git", @@ -129,13 +135,17 @@ "highlightjs-line-numbers.js.zip", "highlightjs-line-numbers.js_visit2.zip", ], - "metadata": {"description": "Line numbering plugin for Highlight.js",}, + "metadata": { + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "description": "Line numbering plugin for Highlight.js", + }, }, { "type": "git", "url": "repo_with_submodules", "archives": ["repo_with_submodules.tgz"], "metadata": { + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", "description": "This is just a sample repository with submodules", }, }, @@ -168,7 +178,7 @@ "tool_configuration": {}, } -ORIGIN_METADATA_KEY = "vcs" +ORIGIN_METADATA_KEY = "keywords" ORIGIN_METADATA_VALUE = "git" ORIGIN_MASTER_REVISION = {}