@@ -30,24 +30,30 @@ def test_client_initialization_region_mismatch():
30
30
"""Test client initialization with region mismatch warning."""
31
31
32
32
with patch ("boto3.client" ) as mock_boto_client :
33
- # First mock a default region when none is specified
34
- mock_client_instance = MagicMock ()
35
- mock_client_instance .meta .region_name = "us-east-1"
36
- mock_boto_client .return_value = mock_client_instance
37
-
38
- # When region_name is not provided, it should use the boto3 default
39
- client1 = MemoryClient ()
40
- assert client1 .region_name == "us-east-1"
41
-
42
- # Reset the mock to test with a specified region
43
- mock_boto_client .reset_mock ()
44
- mock_client_instance = MagicMock ()
45
- mock_client_instance .meta .region_name = "us-west-2"
46
- mock_boto_client .return_value = mock_client_instance
47
-
48
- # When region_name is provided, it should use that value
49
- client2 = MemoryClient (region_name = "us-west-2" )
50
- assert client2 .region_name == "us-west-2"
33
+ with patch ("boto3.Session" ) as mock_session :
34
+ # Mock the session instance
35
+ mock_session_instance = MagicMock ()
36
+ mock_session_instance .region_name = "us-east-1"
37
+ mock_session .return_value = mock_session_instance
38
+
39
+ # Mock the boto client
40
+ mock_client_instance = MagicMock ()
41
+ mock_client_instance .meta .region_name = "us-east-1"
42
+ mock_boto_client .return_value = mock_client_instance
43
+
44
+ # When region_name is not provided, it should use the boto3 default
45
+ client1 = MemoryClient ()
46
+ assert client1 .region_name == "us-east-1"
47
+
48
+ # Reset the mock to test with a specified region
49
+ mock_boto_client .reset_mock ()
50
+ mock_client_instance = MagicMock ()
51
+ mock_client_instance .meta .region_name = "us-west-2"
52
+ mock_boto_client .return_value = mock_client_instance
53
+
54
+ # When region_name is provided, it should use that value
55
+ client2 = MemoryClient (region_name = "us-west-2" )
56
+ assert client2 .region_name == "us-west-2"
51
57
52
58
53
59
def test_namespace_defaults ():
0 commit comments