22from unittest .mock import MagicMock
33from unittest .mock import patch
44
5- from pydantic import Field
65from scim2_models import ComplexAttribute
76from scim2_models import Context
87from scim2_models import EnterpriseUser
1918from scim2_tester .checkers .resource_get import object_query_without_id
2019from scim2_tester .checkers .resource_put import object_replacement
2120from scim2_tester .filling import fill_with_random_values
22- from scim2_tester .utils import CheckConfig
23- from scim2_tester .utils import CheckContext
2421from scim2_tester .utils import Status
2522
2623
@@ -57,21 +54,13 @@ class Type(str, Enum):
5754 complex_unique : Complex | None = None
5855 complex_multiple : list [Complex ] | None = None
5956
60- example_unique : str | None = Field (None , examples = ["foo" , "bar" ])
61- example_multiple : list [str ] | None = Field (None , examples = ["foo" , "bar" ])
6257
63-
64- def test_fill_with_random_values_generates_valid_data ():
58+ def test_fill_with_random_values_generates_valid_data (testing_context ):
6559 """Test that fill_with_random_values populates all fields with valid data."""
66-
67- class MockClient :
68- pass
69-
70- conf = CheckConfig ()
71- context = CheckContext (MockClient (), conf )
72-
7360 obj = CustomModel ()
74- obj = fill_with_random_values (context , obj , context .resource_manager )
61+ obj = fill_with_random_values (
62+ testing_context , obj , testing_context .resource_manager
63+ )
7564
7665 assert obj is not None , (
7766 "fill_with_random_values should not return None for test object"
@@ -83,9 +72,6 @@ class MockClient:
8372
8473 assert getattr (obj , field_name ) is not None
8574
86- assert obj .example_unique in ["foo" , "bar" ]
87- assert all (val in ["foo" , "bar" ] for val in obj .example_multiple )
88-
8975
9076def test_resource_type_tests_with_unknown_schema (testing_context ):
9177 """Test CRUD operations on a resource type with unknown schema."""
@@ -246,27 +232,19 @@ def test_object_deletion_successful(httpserver, testing_context):
246232 assert f"Successfully deleted User object with id { user_id } " in result [0 ].reason
247233
248234
249- def test_object_replacement_fails_when_no_mutable_fields ():
235+ def test_object_replacement_fails_when_no_mutable_fields (testing_context ):
250236 """Test object replacement failure when object cannot be modified."""
251-
252- # Create a context with mock resource manager
253- class MockClient :
254- pass
255-
256- conf = CheckConfig ()
257- context = CheckContext (MockClient (), conf )
258-
259237 # Mock resource manager to avoid HTTP calls
260238 mock_rm = MagicMock ()
261239 mock_rm .create_and_register .return_value = User (id = "test-id" , user_name = "test" )
262- context .resource_manager = mock_rm
240+ testing_context .resource_manager = mock_rm
263241
264242 with patch (
265243 "scim2_tester.checkers.resource_put.fill_with_random_values"
266244 ) as mock_fill :
267245 mock_fill .return_value = None
268246
269- result = object_replacement (context , User )
247+ result = object_replacement (testing_context , User )
270248
271249 # The @checker decorator catches ValueError and returns CheckResult with ERROR status
272250 assert result [0 ].status == Status .ERROR
0 commit comments