1+ from unittest .mock import Mock
2+
13import pytest
4+
25from openstack import exceptions
6+
37from openstack_mcp_server .tools .identity_tools import IdentityTools , Region
4- from unittest .mock import Mock
58
69
710class TestIdentityTools :
@@ -77,7 +80,7 @@ def test_create_region_success(self, mock_get_openstack_conn_identity):
7780
7881 # Verify results
7982 assert result == Region (
80- id = "RegionOne" , description = "Region One description"
83+ id = "RegionOne" , description = "Region One description" ,
8184 )
8285
8386 # Verify mock calls
@@ -109,7 +112,7 @@ def test_create_region_invalid_id_format(self, mock_get_openstack_conn_identity)
109112 # Configure mock region.create_region() to raise an exception
110113 mock_conn .identity .create_region .side_effect = (
111114 exceptions .BadRequestException (
112- "Invalid input for field 'id': Expected string, got integer"
115+ "Invalid input for field 'id': Expected string, got integer" ,
113116 )
114117 )
115118
@@ -132,7 +135,7 @@ def test_delete_region_success(self, mock_get_openstack_conn_identity):
132135 result = identity_tools .delete_region (id = "RegionOne" )
133136
134137 # Verify results
135- assert result == None
138+ assert result is None
136139
137140 # Verify mock calls
138141 mock_conn .identity .delete_region .assert_called_once_with (region = "RegionOne" , ignore_missing = False )
@@ -143,7 +146,7 @@ def test_delete_region_not_found(self, mock_get_openstack_conn_identity):
143146
144147 # Configure mock to raise NotFoundException
145148 mock_conn .identity .delete_region .side_effect = exceptions .NotFoundException (
146- "Region 'RegionOne' not found"
149+ "Region 'RegionOne' not found" ,
147150 )
148151
149152 # Test delete_region()
@@ -206,7 +209,7 @@ def test_update_region_invalid_id_format(self, mock_get_openstack_conn_identity)
206209
207210 # Configure mock region.update_region() to raise an exception
208211 mock_conn .identity .update_region .side_effect = exceptions .BadRequestException (
209- "Invalid input for field 'id': Expected string, got integer"
212+ "Invalid input for field 'id': Expected string, got integer" ,
210213 )
211214
212215 # Test update_region()
@@ -247,7 +250,7 @@ def test_get_region_not_found(self, mock_get_openstack_conn_identity):
247250
248251 # Configure mock to raise NotFoundException
249252 mock_conn .identity .get_region .side_effect = exceptions .NotFoundException (
250- "Region 'RegionOne' not found"
253+ "Region 'RegionOne' not found" ,
251254 )
252255
253256 # Test get_region()
0 commit comments