Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_metadata.py
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | def test_api_raw_extrinsic_metadata_check_params( | ||||
api_client, archive_data, status_code, url_args, query_params | api_client, archive_data, status_code, url_args, query_params | ||||
): | ): | ||||
url = reverse( | url = reverse( | ||||
"api-1-raw-extrinsic-metadata-swhid", | "api-1-raw-extrinsic-metadata-swhid", | ||||
url_args=url_args, | url_args=url_args, | ||||
query_params=query_params, | query_params=query_params, | ||||
) | ) | ||||
check_api_get_responses(api_client, url, status_code=status_code) | check_api_get_responses(api_client, url, status_code=status_code) | ||||
@given(raw_extrinsic_metadata()) | |||||
def test_api_raw_extrinsic_metadata_list_authorities( | |||||
api_client, archive_data, metadata | |||||
): | |||||
archive_data.metadata_authority_add([metadata.authority]) | |||||
archive_data.metadata_fetcher_add([metadata.fetcher]) | |||||
archive_data.raw_extrinsic_metadata_add([metadata]) | |||||
authority = metadata.authority | |||||
url = reverse( | |||||
"api-1-raw-extrinsic-metadata-swhid-authorities", | |||||
url_args={"target": str(metadata.target)}, | |||||
) | |||||
rv = check_api_get_responses(api_client, url, status_code=200) | |||||
expected_results = [ | |||||
{ | |||||
"type": authority.type.value, | |||||
"url": authority.url, | |||||
"metadata_list_url": "http://testserver" | |||||
+ reverse( | |||||
"api-1-raw-extrinsic-metadata-swhid", | |||||
url_args={"target": str(metadata.target)}, | |||||
query_params={"authority": f"{authority.type.value} {authority.url}"}, | |||||
), | |||||
} | |||||
] | |||||
assert rv.data == expected_results |