diff --git a/openformsclient/client.py b/openformsclient/client.py index 599ded2..dd49dc6 100644 --- a/openformsclient/client.py +++ b/openformsclient/client.py @@ -35,14 +35,14 @@ def is_healthy(self) -> Tuple[bool, str]: try: # We do a head request to actually hit a protected endpoint without # getting a whole bunch of data. - response = self._request("head", "forms") + response = self._request("head", "public/forms") response.raise_for_status() return (True, "") except HTTPError as e: # If something is wrong, we might get more information from the # error message provided by Open Forms. try: - response = self._request("get", "forms") + response = self._request("get", "public/forms") data = response.json() message = ( data.get("detail", data.get("title")) @@ -62,7 +62,7 @@ def get_forms(self) -> list: :returns: The API response content as Python object. """ - response = self._request("get", "forms") + response = self._request("get", "public/forms") response.raise_for_status() return response.json() diff --git a/tests/test_client.py b/tests/test_client.py index 00b473f..4701367 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -11,7 +11,7 @@ @requests_mock.Mocker() class ClientTests(TestCase): def setUp(self): - self.api_root = "https://example.com/api/v1/" + self.api_root = "https://example.com/api/v2/" self.api_token = "token" self.client_timeout = 2 self.client = Client(self.api_root, self.api_token, self.client_timeout) @@ -22,7 +22,7 @@ def test_has_config(self, m): def test_is_healthy(self, m): m.head( - f"{self.api_root}forms", + f"{self.api_root}public/forms", request_headers={"Authorization": f"Token {self.api_token}"}, ) @@ -31,17 +31,17 @@ def test_is_healthy(self, m): self.assertEqual(msg, "") def test_is_healthy_invalid_response(self, m): - m.head(f"{self.api_root}forms", status_code=500) # Doesn't really matter - m.get(f"{self.api_root}forms", text="Woops") + m.head(f"{self.api_root}public/forms", status_code=500) # Doesn't really matter + m.get(f"{self.api_root}public/forms", text="Woops") health, msg = self.client.is_healthy() self.assertFalse(health) self.assertEqual(msg, "Server did not return a valid response (HTTP 500).") def test_is_healthy_invalid_token(self, m): - m.head(f"{self.api_root}forms", status_code=401) + m.head(f"{self.api_root}public/forms", status_code=401) m.get( - f"{self.api_root}forms", + f"{self.api_root}public/forms", json={ "type": "https://example.com/fouten/AuthenticationFailed/", "code": "authentication_failed", @@ -57,13 +57,13 @@ def test_is_healthy_invalid_token(self, m): self.assertEqual(msg, "Ongeldige token.") def test_get_forms(self, m): - m.get(f"{self.api_root}forms", json=[]) + m.get(f"{self.api_root}public/forms", json=[]) result = self.client.get_forms() self.assertListEqual(result, []) def test_get_forms_with_error(self, m): - m.get(f"{self.api_root}forms", status_code=401) + m.get(f"{self.api_root}public/forms", status_code=401) with self.assertRaises(HTTPError): self.client.get_forms() @@ -85,7 +85,7 @@ def test_request_uses_configured_timeout(self, m): self.client.get_form("myform") mock_request.assert_called_with( "get", - "https://example.com/api/v1/forms/myform", + "https://example.com/api/v2/forms/myform", headers={"Authorization": "Token token"}, timeout=2, ) diff --git a/tests/test_integration.py b/tests/test_integration.py index 5a5d5e3..4aad5eb 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -21,7 +21,7 @@ def setUp(self): def _prepare_mock(self, m): m.get( - f"{self.config.api_root}forms", + f"{self.config.api_root}public/forms", json=[ { "uuid": "1b0d0675-2caf-48e8-beda-c32c6732b63c", diff --git a/tests/test_utils.py b/tests/test_utils.py index 64f325d..0f17ec9 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -22,7 +22,7 @@ def test_get_form_choices_without_config(self, m): def test_get_form_choices_without_client(self, m): m.get( - f"{self.config.api_root}forms", + f"{self.config.api_root}public/forms", json=[ { "uuid": "1b0d0675-2caf-48e8-beda-c32c6732b63c", @@ -49,7 +49,7 @@ def test_get_form_choices_without_client(self, m): def test_get_form_choices_with_client(self, m): m.get( - f"{self.config.api_root}forms", + f"{self.config.api_root}public/forms", json=[ { "uuid": "1b0d0675-2caf-48e8-beda-c32c6732b63c", @@ -76,7 +76,7 @@ def test_get_form_choices_with_client(self, m): def test_get_form_choices_use_uuids(self, m): m.get( - f"{self.config.api_root}forms", + f"{self.config.api_root}public/forms", json=[ { "uuid": "1b0d0675-2caf-48e8-beda-c32c6732b63c",