Skip to content

Commit 8c29618

Browse files
committed
[#3688] Refactor config to a helper function
1 parent 892b258 commit 8c29618

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/openforms/registrations/contrib/objects_api/tests/test_objecttypes_client.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@
1111
from ..client import get_objecttypes_client
1212
from ..models import ObjectsAPIConfig
1313

14-
OBJECTTYPES_API_BASE_URL = "http://localhost:8001/api/v2/"
1514

16-
# The value is the API key loaded in the docker service:
17-
OBJECTTYPES_API_KEY = "171be5abaf41e7856b423ad513df1ef8f867ff48"
15+
def get_test_config() -> ObjectsAPIConfig:
16+
"""Returns a preconfigured ``ObjectsAPIConfig`` instance matching the docker compose configuration."""
17+
return ObjectsAPIConfig(
18+
objecttypes_service=Service(
19+
api_root="http://localhost:8001/api/v2/",
20+
api_type=APITypes.orc,
21+
oas="https://example.com/",
22+
header_key="Authorization",
23+
header_value="Token 171be5abaf41e7856b423ad513df1ef8f867ff48",
24+
auth_type=AuthTypes.api_key,
25+
)
26+
)
1827

1928

2029
class ObjecttypesClientTest(OFVCRMixin, TestCase):
@@ -26,16 +35,7 @@ def setUp(self) -> None:
2635

2736
patcher = patch(
2837
"openforms.registrations.contrib.objects_api.client.ObjectsAPIConfig.get_solo",
29-
return_value=ObjectsAPIConfig(
30-
objecttypes_service=Service(
31-
api_root=OBJECTTYPES_API_BASE_URL,
32-
api_type=APITypes.orc,
33-
oas="https://example.com/",
34-
header_key="Authorization",
35-
header_value=f"Token {OBJECTTYPES_API_KEY}",
36-
auth_type=AuthTypes.api_key,
37-
)
38-
),
38+
return_value=get_test_config(),
3939
)
4040

4141
self.config_mock = patcher.start()

0 commit comments

Comments
 (0)