diff --git a/acceptance_tests/app/c2cwsgiutils_app/services.py b/acceptance_tests/app/c2cwsgiutils_app/services.py index f4b1edd2a..c3589aa0a 100644 --- a/acceptance_tests/app/c2cwsgiutils_app/services.py +++ b/acceptance_tests/app/c2cwsgiutils_app/services.py @@ -98,7 +98,13 @@ def tracking(request): @empty_service.put() -def empty(request): +def empty_put(request): + request.response.status_code = 204 + return request.response + + +@empty_service.patch() +def empty_patch(request): request.response.status_code = 204 return request.response diff --git a/acceptance_tests/tests/tests/test_connection.py b/acceptance_tests/tests/tests/test_connection.py index 6e3864ebe..f2cb6aa51 100644 --- a/acceptance_tests/tests/tests/test_connection.py +++ b/acceptance_tests/tests/tests/test_connection.py @@ -1,2 +1,6 @@ def test_empty_response(app_connection): assert app_connection.put_json("empty", expected_status=204) is None + + +def test_empty_response(app_connection): + assert app_connection.patch_json("empty", expected_status=204) is None diff --git a/c2cwsgiutils/acceptance/connection.py b/c2cwsgiutils/acceptance/connection.py index 51aa538e3..eb5a3b226 100644 --- a/c2cwsgiutils/acceptance/connection.py +++ b/c2cwsgiutils/acceptance/connection.py @@ -159,12 +159,29 @@ def put_json( cache_expected: CacheExpected = CacheExpected.NO, **kwargs: Any, ) -> Any: - """POST the given URL (relative to the root of API).""" + """PUT the given URL (relative to the root of API).""" with self.session.put(self.base_url + url, headers=self._merge_headers(headers, cors), **kwargs) as r: check_response(r, expected_status, cache_expected) self._check_cors(cors, r) return _get_json(r) + def patch_json( + self, + url: str, + expected_status: int = 200, + headers: Optional[Mapping[str, str]] = None, + cors: bool = True, + cache_expected: CacheExpected = CacheExpected.NO, + **kwargs: Any, + ) -> Any: + """PATCH the given URL (relative to the root of API).""" + with self.session.patch( + self.base_url + url, headers=self._merge_headers(headers, cors), **kwargs + ) as r: + check_response(r, expected_status, cache_expected) + self._check_cors(cors, r) + return _get_json(r) + def delete( self, url: str,