Skip to content

Commit 1ea3b4e

Browse files
committed
fix: rename package (#35)
- Align nameing (keystone->identity) and add Mock import in tests - fix ruff violations in test/tools - added missing Mock import in test_identity_tools.py - rename keystone references to identity in test_identity_tools.py by. jja6312@ Close #35
1 parent eae2194 commit 1ea3b4e

File tree

4 files changed

+206
-114
lines changed

4 files changed

+206
-114
lines changed

src/openstack_mcp_server/tools/identity_tools.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from fastmcp import FastMCP
2+
13
from .base import get_openstack_conn
24
from .response.keystone import Region
3-
from fastmcp import FastMCP
45

56

67
class IdentityTools:
@@ -35,7 +36,6 @@ def get_regions(self) -> list[Region]:
3536

3637
return region_list
3738

38-
3939
def get_region(self, id: str) -> Region:
4040
"""
4141
Get a region.
@@ -92,9 +92,11 @@ def update_region(self, id: str, description: str = "") -> Region:
9292
conn = get_openstack_conn()
9393

9494
updated_region = conn.identity.update_region(
95-
region=id, description=description
95+
region=id,
96+
description=description,
9697
)
9798

9899
return Region(
99-
id=updated_region.id, description=updated_region.description
100+
id=updated_region.id,
101+
description=updated_region.description,
100102
)

tests/tools/test_compute_tools.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from unittest.mock import Mock, call
2-
from openstack_mcp_server.tools.response.compute import Server
2+
33
from openstack_mcp_server.tools.compute_tools import ComputeTools
4+
from openstack_mcp_server.tools.response.compute import Server
5+
46

57
class TestComputeTools:
68
"""Test cases for ComputeTools class."""
@@ -76,13 +78,16 @@ def test_get_compute_servers_single_server(self, mock_get_openstack_conn):
7678
result = compute_tools.get_compute_servers()
7779

7880
expected_output = [
79-
Server(name="test-server", id="single-123", status="BUILDING")
81+
Server(name="test-server", id="single-123", status="BUILDING"),
8082
]
8183
assert result == expected_output
8284

8385
mock_conn.compute.servers.assert_called_once()
8486

85-
def test_get_compute_servers_multiple_statuses(self, mock_get_openstack_conn):
87+
def test_get_compute_servers_multiple_statuses(
88+
self,
89+
mock_get_openstack_conn,
90+
):
8691
"""Test servers with various statuses."""
8792
mock_conn = mock_get_openstack_conn
8893

@@ -119,8 +124,10 @@ def test_get_compute_servers_multiple_statuses(self, mock_get_openstack_conn):
119124

120125
mock_conn.compute.servers.assert_called_once()
121126

122-
def test_get_compute_servers_with_special_characters(self, mock_get_openstack_conn):
123-
127+
def test_get_compute_servers_with_special_characters(
128+
self,
129+
mock_get_openstack_conn,
130+
):
124131
"""Test servers with special characters in names."""
125132
mock_conn = mock_get_openstack_conn
126133

@@ -142,7 +149,9 @@ def test_get_compute_servers_with_special_characters(self, mock_get_openstack_co
142149

143150
assert (
144151
Server(
145-
name="web-server_test-01", id="id-with-dashes", status="ACTIVE"
152+
name="web-server_test-01",
153+
id="id-with-dashes",
154+
status="ACTIVE",
146155
)
147156
in result
148157
)
@@ -162,19 +171,21 @@ def test_register_tools(self):
162171

163172
compute_tools = ComputeTools()
164173
compute_tools.register_tools(mock_mcp)
165-
166-
mock_tool_decorator.assert_has_calls([
167-
call(compute_tools.get_compute_servers),
168-
call(compute_tools.get_compute_server)
169-
])
174+
175+
mock_tool_decorator.assert_has_calls(
176+
[
177+
call(compute_tools.get_compute_servers),
178+
call(compute_tools.get_compute_server),
179+
],
180+
)
170181
assert mock_tool_decorator.call_count == 2
171182

172183
def test_compute_tools_instantiation(self):
173184
"""Test ComputeTools can be instantiated."""
174185
compute_tools = ComputeTools()
175186
assert compute_tools is not None
176-
assert hasattr(compute_tools, 'register_tools')
177-
assert hasattr(compute_tools, 'get_compute_servers')
187+
assert hasattr(compute_tools, "register_tools")
188+
assert hasattr(compute_tools, "get_compute_servers")
178189
assert callable(compute_tools.register_tools)
179190
assert callable(compute_tools.get_compute_servers)
180191

0 commit comments

Comments
 (0)