From 84e249d644104bf61c9037ee99b12faa8e3c72e1 Mon Sep 17 00:00:00 2001 From: lowit Date: Wed, 18 Nov 2020 17:22:56 +0300 Subject: [PATCH 1/2] issue-68: adds test --- http_stubs/tests/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http_stubs/tests/tests.py b/http_stubs/tests/tests.py index c12dff6..2aff2fa 100644 --- a/http_stubs/tests/tests.py +++ b/http_stubs/tests/tests.py @@ -98,7 +98,7 @@ def test_exist_regexp_stub(self, method: str, http_stub_factory, client): } http_stub_factory( method=method, - path=r'/test/\d+/', + path=r'/test/\d+/\?arg=\w+', regex_path=True, resp_body=resp_body, resp_status=resp_status, @@ -106,7 +106,7 @@ def test_exist_regexp_stub(self, method: str, http_stub_factory, client): resp_headers=resp_headers, ) resp_method = method.lower() - response = getattr(client, resp_method)('/test/100500/') + response = getattr(client, resp_method)('/test/100500/?arg=test') if method != HTTPMethod.HEAD.name: assert response.content == resp_body.encode('utf-8') From 8c06543d91a7331ca1e74245969cb31296bfdea3 Mon Sep 17 00:00:00 2001 From: lowit Date: Wed, 18 Nov 2020 17:25:07 +0300 Subject: [PATCH 2/2] issue-68: replaces request path with the full path with request arguments --- http_stubs/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http_stubs/views.py b/http_stubs/views.py index 3e22427..c374001 100644 --- a/http_stubs/views.py +++ b/http_stubs/views.py @@ -44,7 +44,7 @@ def dispatch(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: :param kwargs: request kwargs :returns: http response """ - stub = self.find_stub(request.method, f'/{kwargs["path"]}') + stub = self.find_stub(request.method, request.get_full_path()) if not stub: return HttpResponseNotFound() LogEntry.objects.create(