44from capi_janitor .openstack .openstack import AuthenticationError , Cloud
55
66
7- class TestCloudAenter (unittest .IsolatedAsyncioTestCase ):
7+ class TestCloudAsyncContext (unittest .IsolatedAsyncioTestCase ):
88 # Set up common variables for all tests
99 async def asyncSetUp (self ):
1010 # Auth is mocked to simulate authentication
@@ -19,7 +19,7 @@ async def asyncSetUp(self):
1919
2020 # Test the __aenter__ method for auth success and general functionality
2121 @patch ("capi_janitor.openstack.openstack.Client" )
22- async def test_aenter_successful_authentication (self , mock_client ):
22+ async def test_cloud_successful_authentication (self , mock_client ):
2323 # Patched client to simulate a successful authentication
2424 mock_client_instance = AsyncMock ()
2525 # Return mock for the client
@@ -55,7 +55,7 @@ async def test_aenter_successful_authentication(self, mock_client):
5555
5656 # Test the __aenter__ method for auth failure
5757 @patch ("capi_janitor.openstack.openstack.Client" )
58- async def test_aenter_authentication_failure (self , mock_client ):
58+ async def test_cloud_authentication_failure (self , mock_client ):
5959 mock_client_instance = AsyncMock ()
6060 mock_client .return_value = mock_client_instance
6161 # Simulate an auth error with a named user
@@ -71,7 +71,7 @@ async def test_aenter_authentication_failure(self, mock_client):
7171
7272 # Test the __aenter__ method for 404 error
7373 @patch ("capi_janitor.openstack.openstack.Client" )
74- async def test_aenter_404_error (self , mock_client ):
74+ async def test_cloud_auth_404_error (self , mock_client ):
7575 mock_client_instance = AsyncMock ()
7676 mock_client .return_value = mock_client_instance
7777 # Simulate a 404 error
@@ -86,7 +86,7 @@ async def test_aenter_404_error(self, mock_client):
8686
8787 # Test the __aenter__ method for no matching interface
8888 @patch ("capi_janitor.openstack.openstack.Client" )
89- async def test_aenter_no_matching_interface (self , mock_client ):
89+ async def test_cloud_no_matching_interface (self , mock_client ):
9090 mock_client_instance = AsyncMock ()
9191 mock_client .return_value = mock_client_instance
9292 # No matching interface in the response
@@ -112,7 +112,7 @@ async def test_aenter_no_matching_interface(self, mock_client):
112112 self .assertEqual (cloud .apis , [])
113113
114114 @patch ("capi_janitor.openstack.openstack.Client" )
115- async def test_aenter_no_matching_region_id (self , mock_client ):
115+ async def test_cloud_no_matching_region_id (self , mock_client ):
116116 mock_client_instance = AsyncMock ()
117117 mock_client .return_value = mock_client_instance
118118 # No matching region_id in the response
@@ -138,7 +138,7 @@ async def test_aenter_no_matching_region_id(self, mock_client):
138138 self .assertEqual (cloud .apis , [])
139139
140140 @patch ("capi_janitor.openstack.openstack.Client" )
141- async def test_aenter_filter_endpoints (self , mock_client ):
141+ async def test_cloud_filter_endpoints (self , mock_client ):
142142 mock_client_instance = AsyncMock ()
143143 mock_client .return_value = mock_client_instance
144144 # Return multiple endpoints, one matching, one not
@@ -175,7 +175,7 @@ async def test_aenter_filter_endpoints(self, mock_client):
175175 self .assertNotIn ("network" , cloud .apis )
176176
177177 @patch ("capi_janitor.openstack.openstack.Client" )
178- async def test_aenter_multiple_services (self , mock_client ):
178+ async def test_cloud_multiple_services (self , mock_client ):
179179 mock_client_instance = AsyncMock ()
180180 mock_client .return_value = mock_client_instance
181181 # Return multiple services, some matching, some not
@@ -223,7 +223,7 @@ async def test_aenter_multiple_services(self, mock_client):
223223 self .assertIn ("network" , cloud .apis )
224224
225225 @patch ("capi_janitor.openstack.openstack.Client" )
226- async def test_aenter_empty_endpoint_list (self , mock_client ):
226+ async def test_cloud_empty_endpoint_list (self , mock_client ):
227227 mock_client_instance = AsyncMock ()
228228 mock_client .return_value = mock_client_instance
229229 mock_client_instance .get .return_value .json = MagicMock (
@@ -234,7 +234,7 @@ async def test_aenter_empty_endpoint_list(self, mock_client):
234234 self .assertFalse (cloud .is_authenticated )
235235
236236 @patch ("capi_janitor.openstack.openstack.Client" )
237- async def test_aenter_no_region_specified (self , mock_client ):
237+ async def test_cloud_no_region_specified (self , mock_client ):
238238 # Set up the cloud instance without a region
239239 self .cloud = Cloud (self .auth , self .transport , self .interface , region = None )
240240 mock_client_instance = AsyncMock ()
0 commit comments