api_client = <rest_framework.test.APIClient object at 0x7fcd46f5a320>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fcd46f5a2b0>
backend = 'swh-indexer-storage'
@pytest.mark.parametrize("backend", ["swh-search", "swh-indexer-storage"])
def test_api_origin_metadata_search(api_client, mocker, backend):
mock_config = mocker.patch("swh.web.common.archive.config")
mock_config.get_config.return_value = {"metadata_search_backend": backend}
url = reverse(
"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"],
},
"mappings": [],
},
}
for origin_url, master_rev in ORIGIN_MASTER_REVISION.items()
]
for i in range(len(expected_data)):
expected = expected_data[i]
response = rv.data[i]
metadata = response["metadata"].pop("metadata")
assert any(
[ORIGIN_METADATA_VALUE in json.dumps(val) for val in metadata.values()]
)
> assert response == expected
E AssertionError: assert {'metadata': ...e-numbers.js'} == {'metadata': ...nen/libtess2'}
E Differing items:
E {'url': 'https://github.com/wcoder/highlightjs-line-numbers.js'} != {'url': 'https://github.com/memononen/libtess2'}
E {'metadata': {'from_revision': '3bd01955e961aa2e6e1b6f9cd9e003f94273584e', 'mappings': [], 'tool': {'configuration': {}, 'id': -5506452438712624223, 'name': 'swh-web tests', 'version': '1.0'}}} != {'metadata': {'from_revision': '56d5c87b596bfe792f79b2e41fde83b769f6406d', 'mappings': [], 'tool': {'configuration': {}, 'id': -5506452438712624223, 'name': 'swh-web tests', 'version': '1.0'}}}
E Full diff:
E {
E - 'metadata': {'from_revision': '56d5c87...
E
E ...Full output truncated (10 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_origin.py:608: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Jul 7 2021, 3:48 PM