client = <django.test.client.Client object at 0x7f45e50944e0>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f45e5094588>
keycloak_oidc = <swh.auth.pytest_plugin.KeycloackOpenIDConnectMock object at 0x7f45e5094748>
@pytest.mark.django_db
def test_save_origin_requests_list_user_filter(client, mocker, keycloak_oidc):
# anonymous user created a save request
sor = SaveOriginRequest.objects.create(
request_date=datetime.now(tz=timezone.utc),
visit_type="svn",
origin_url="https://svn.example.org/user/project",
status=SAVE_REQUEST_ACCEPTED,
visit_date=datetime.now(tz=timezone.utc) + timedelta(hours=1),
loading_task_id=1,
loading_task_status=SAVE_TASK_SUCCEEDED,
)
# authenticated user created a save request
user = oidc_user_from_profile(keycloak_oidc, keycloak_oidc.login())
client.login(code="", code_verifier="", redirect_uri="")
sor = SaveOriginRequest.objects.create(
request_date=datetime.now(tz=timezone.utc),
visit_type="git",
origin_url="https://git.example.org/user/project",
status=SAVE_REQUEST_ACCEPTED,
visit_date=datetime.now(tz=timezone.utc) + timedelta(hours=1),
loading_task_id=2,
loading_task_status=SAVE_TASK_SUCCEEDED,
user_ids=f'"{user.id}"',
)
# filter save requests according to user id
url = reverse(
"origin-save-requests-list",
url_args={"status": "all"},
query_params={
"draw": 1,
"search[value]": "",
"order[0][column]": "0",
"columns[0][name]": "request_date",
"order[0][dir]": "desc",
"length": 10,
"start": "0",
> "user_requests_only": "1",
},
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/misc/test_origin_save.py:143:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
viewname = 'origin-save-requests-list', url_args = {'status': 'all'}
query_params = {'columns[0][name]': 'request_date', 'draw': 1, 'length': 10, 'order[0][column]': '0', ...}
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(1, 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