api_client = <rest_framework.test.APIClient object at 0x7f45dece9390>
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7f45dece9438>
status_code = 200
url_args = {'target': 'swh:1:dir:a2faa28028657859c16ff506924212b33f0e1307'}
query_params = {'after': '2021-06-18T09:31:09', 'authority': 'forge http://example.org', 'limit': 100}
@pytest.mark.parametrize(
"status_code,url_args,query_params",
[
pytest.param(
200,
{"target": _swhid},
{"authority": "forge http://example.org"},
id="minimal working",
),
pytest.param(
200,
{"target": _swhid},
{
"authority": "forge http://example.org",
"after": "2021-06-18T09:31:09",
"limit": 100,
},
id="maximal working",
),
pytest.param(
400,
{"target": _swhid},
{"authority": "foo http://example.org"},
id="invalid authority type",
),
pytest.param(
400,
{"target": _swhid},
{
"authority": "forge http://example.org",
"after": "yesterday",
},
id="invalid 'after' format",
),
pytest.param(
400,
{"target": _swhid},
{
"authority": "forge http://example.org",
"limit": "abc",
},
id="invalid 'limit'",
),
],
)
def test_api_raw_extrinsic_metadata_check_params(
api_client, archive_data, status_code, url_args, query_params
):
url = reverse(
"api-1-raw-extrinsic-metadata-swhid",
url_args=url_args,
> query_params=query_params,
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/api/views/test_metadata.py:177:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
viewname = 'api-1-raw-extrinsic-metadata-swhid'
url_args = {'target': 'swh:1:dir:a2faa28028657859c16ff506924212b33f0e1307'}
query_params = {'after': '2021-06-18T09:31:09', 'authority': 'forge http://example.org', 'limit': 100}
current_app = None, urlconf = None, request = None
def reverse(
viewname: str,
url_args: Optional[Dict[str, Any]] = None,
query_params: Optional[QueryParameters] = None,
current_app: Optional[str] = None,
urlconf: Optional[str] = None,
request: Optional[HttpRequest] = None,
) -> str:
"""An override of django reverse function supporting query parameters.
Args:
viewname: the name of the django view from which to compute a url
url_args: dictionary of url arguments indexed by their names
query_params: dictionary of query parameters to append to the
reversed url
current_app: the name of the django app tighten to the view
urlconf: url configuration module
request: build an absolute URI if provided
Returns:
str: the url of the requested view with processed arguments and
query parameters
"""
if url_args:
url_args = {k: v for k, v in url_args.items() if v is not None}
url = django_reverse(
viewname, urlconf=urlconf, kwargs=url_args, current_app=current_app
)
if query_params:
query_params_dict = {k: v for k, v in query_params.items() if v is not None}
if len(query_params_dict) > 0:
query_dict = QueryDict("", mutable=True)
for k in sorted(query_params_dict.keys()):
value = query_params_dict[k]
> assert isinstance(value, str)
E assert False
E + where False = isinstance(100, str)
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:104: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 25 2022, 4:46 PM