@@ -305,28 +305,22 @@ def test_user_attribute_sync_form_spec_choices(
305305 ]
306306
307307
308- def _editable_connection_elements (
309- monkeypatch : pytest .MonkeyPatch , * , saml_supported : bool
310- ) -> list [Any ]:
308+ def _editable_connection_elements (* , saml_supported : bool ) -> list [Any ]:
311309 """Return the per-entry connection choices of the nested ``"list"`` widget
312- with stubbed connection choices."""
313- monkeypatch .setattr ("cmk.gui.watolib.sites.connection_choices" , lambda : [("ldap_a" , "LDAP A" )])
314- monkeypatch .setattr (
315- "cmk.gui.watolib.sites.saml_connection_choices" , lambda : [("saml_a" , "SAML A" )]
316- )
317- monkeypatch .setattr ("cmk.gui.watolib.sites.distributed_saml_supported" , lambda : saml_supported )
318- template = SiteManagement ._editable_connections_form_spec ().element_template
310+ built from stubbed connection choices."""
311+ template = SiteManagement ._editable_connections_form_spec (
312+ ldap_choices = [("ldap_a" , "LDAP A" )],
313+ saml_choices = [("saml_a" , "SAML A" )] if saml_supported else None ,
314+ ).element_template
319315 assert hasattr (template , "elements" )
320316 return list (template .elements )
321317
322318
323- def test_editable_connections_form_spec_offers_ldap_and_saml_when_supported (
324- request_context : None , monkeypatch : pytest .MonkeyPatch
325- ) -> None :
319+ def test_editable_connections_form_spec_offers_ldap_and_saml_when_supported () -> None :
326320 """The nested "list" connection widget renders an LDAP pick and, when distributed
327321 SAML is supported, a SAML pick whose sub-form carries the connection_id,
328322 metadata_endpoint and acs_endpoint fields."""
329- elements = _editable_connection_elements (monkeypatch , saml_supported = True )
323+ elements = _editable_connection_elements (saml_supported = True )
330324 assert [element .name for element in elements ] == ["ldap" , "saml" ]
331325 assert [choice .name for choice in elements [0 ].parameter_form .elements ] == ["ldap_a" ]
332326 saml_subform = elements [1 ].parameter_form
@@ -336,9 +330,7 @@ def test_editable_connections_form_spec_offers_ldap_and_saml_when_supported(
336330 ] == ["saml_a" ]
337331
338332
339- def test_connection_pick_accepts_dash_in_connection_id (
340- request_context : None , monkeypatch : pytest .MonkeyPatch
341- ) -> None :
333+ def test_connection_pick_accepts_dash_in_connection_id () -> None :
342334 """A connection id containing a dash can be offered as a per-site pick.
343335
344336 The product's own id rule (the ``ID`` valuespec behind the connection's "ID"
@@ -347,15 +339,10 @@ def test_connection_pick_accepts_dash_in_connection_id(
347339 otherwise required to be Python identifiers, which a dash is not — so
348340 building the pick must not choke on an id the creation form let through.
349341 """
350- monkeypatch .setattr (
351- "cmk.gui.watolib.sites.connection_choices" , lambda : [("ldap-with-dash" , "LDAP dashed" )]
352- )
353- monkeypatch .setattr (
354- "cmk.gui.watolib.sites.saml_connection_choices" , lambda : [("saml-with-dash" , "SAML dashed" )]
355- )
356- monkeypatch .setattr ("cmk.gui.watolib.sites.distributed_saml_supported" , lambda : True )
357-
358- template = SiteManagement ._editable_connections_form_spec ().element_template
342+ template = SiteManagement ._editable_connections_form_spec (
343+ ldap_choices = [("ldap-with-dash" , "LDAP dashed" )],
344+ saml_choices = [("saml-with-dash" , "SAML dashed" )],
345+ ).element_template
359346 assert hasattr (template , "elements" )
360347 elements = list (template .elements )
361348
@@ -377,9 +364,7 @@ def test_auth_connections_round_trip_dashed_connection_id() -> None:
377364 assert _auth_connections_to_disk (("list" , entries )) == entries
378365
379366
380- def test_editable_connections_form_spec_omits_saml_when_not_supported (
381- request_context : None , monkeypatch : pytest .MonkeyPatch
382- ) -> None :
367+ def test_editable_connections_form_spec_omits_saml_when_not_supported () -> None :
383368 """Without distributed SAML support the nested "list" widget offers only the LDAP pick."""
384- elements = _editable_connection_elements (monkeypatch , saml_supported = False )
369+ elements = _editable_connection_elements (saml_supported = False )
385370 assert [element .name for element in elements ] == ["ldap" ]
0 commit comments