Skip to content

Commit c107935

Browse files
caputdraconis050630halucinor
authored andcommitted
refactor: function naming convention
1 parent 5ba3b50 commit c107935

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

src/openstack_mcp_server/tools/block_storage_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def register_tools(self, mcp: FastMCP):
1515
"""
1616
Register Block Storage-related tools with the FastMCP instance.
1717
"""
18-
mcp.tool()(self.get_block_storage_volumes)
18+
mcp.tool()(self.get_volumes)
1919
mcp.tool()(self.get_volume_details)
2020
mcp.tool()(self.create_volume)
2121
mcp.tool()(self.delete_volume)
2222
mcp.tool()(self.extend_volume)
2323

24-
def get_block_storage_volumes(self) -> list[Volume]:
24+
def get_volumes(self) -> list[Volume]:
2525
"""
2626
Get the list of Block Storage volumes.
2727

tests/tools/test_block_storage_tools.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
class TestBlockStorageTools:
1111
"""Test cases for BlockStorageTools class."""
1212

13-
def test_get_block_storage_volumes_success(self, mock_get_openstack_conn_block_storage):
14-
"""Test getting block storage volumes successfully."""
13+
def test_get_volumes_success(self, mock_get_openstack_conn_block_storage):
14+
"""Test getting volumes successfully."""
1515
mock_conn = mock_get_openstack_conn_block_storage
1616

1717
# Create mock volume objects
@@ -49,7 +49,7 @@ def test_get_block_storage_volumes_success(self, mock_get_openstack_conn_block_s
4949

5050
# Test BlockStorageTools
5151
block_storage_tools = BlockStorageTools()
52-
result = block_storage_tools.get_block_storage_volumes()
52+
result = block_storage_tools.get_volumes()
5353

5454
# Verify results
5555
assert isinstance(result, list)
@@ -73,28 +73,28 @@ def test_get_block_storage_volumes_success(self, mock_get_openstack_conn_block_s
7373
# Verify mock calls
7474
mock_conn.block_storage.volumes.assert_called_once()
7575

76-
def test_get_block_storage_volumes_empty_list(
76+
def test_get_volumes_empty_list(
7777
self, mock_get_openstack_conn_block_storage
7878
):
79-
"""Test getting block storage volumes when no volumes exist."""
79+
"""Test getting volumes when no volumes exist."""
8080
mock_conn = mock_get_openstack_conn_block_storage
8181

8282
# Empty volume list
8383
mock_conn.block_storage.volumes.return_value = []
8484

8585
block_storage_tools = BlockStorageTools()
86-
result = block_storage_tools.get_block_storage_volumes()
86+
result = block_storage_tools.get_volumes()
8787

8888
# Verify empty list
8989
assert isinstance(result, list)
9090
assert len(result) == 0
9191

9292
mock_conn.block_storage.volumes.assert_called_once()
9393

94-
def test_get_block_storage_volumes_single_volume(
94+
def test_get_volumes_single_volume(
9595
self, mock_get_openstack_conn_block_storage
9696
):
97-
"""Test getting block storage volumes with a single volume."""
97+
"""Test getting volumes with a single volume."""
9898
mock_conn = mock_get_openstack_conn_block_storage
9999

100100
# Single volume
@@ -105,7 +105,7 @@ def test_get_block_storage_volumes_single_volume(
105105
mock_volume.size = 5
106106
mock_volume.volume_type = None
107107
mock_volume.availability_zone = "nova"
108-
mock_volume.created_at = None
108+
mock_volume.created_at = "2024-01-01T12:00:00Z"
109109
mock_volume.is_bootable = False
110110
mock_volume.is_encrypted = False
111111
mock_volume.description = None
@@ -114,7 +114,7 @@ def test_get_block_storage_volumes_single_volume(
114114
mock_conn.block_storage.volumes.return_value = [mock_volume]
115115

116116
block_storage_tools = BlockStorageTools()
117-
result = block_storage_tools.get_block_storage_volumes()
117+
result = block_storage_tools.get_volumes()
118118

119119
assert isinstance(result, list)
120120
assert len(result) == 1
@@ -124,7 +124,7 @@ def test_get_block_storage_volumes_single_volume(
124124

125125
mock_conn.block_storage.volumes.assert_called_once()
126126

127-
def test_get_block_storage_volumes_multiple_statuses(
127+
def test_get_volumes_multiple_statuses(
128128
self, mock_get_openstack_conn_block_storage
129129
):
130130
"""Test volumes with various statuses."""
@@ -158,7 +158,7 @@ def test_get_block_storage_volumes_multiple_statuses(
158158
mock_conn.block_storage.volumes.return_value = mock_volumes
159159

160160
block_storage_tools = BlockStorageTools()
161-
result = block_storage_tools.get_block_storage_volumes()
161+
result = block_storage_tools.get_volumes()
162162

163163
# Verify result is a list with correct length
164164
assert isinstance(result, list)
@@ -174,7 +174,7 @@ def test_get_block_storage_volumes_multiple_statuses(
174174

175175
mock_conn.block_storage.volumes.assert_called_once()
176176

177-
def test_get_block_storage_volumes_with_special_characters(
177+
def test_get_volumes_with_special_characters(
178178
self, mock_get_openstack_conn_block_storage
179179
):
180180
"""Test volumes with special characters in names."""
@@ -213,7 +213,7 @@ def test_get_block_storage_volumes_with_special_characters(
213213
]
214214

215215
block_storage_tools = BlockStorageTools()
216-
result = block_storage_tools.get_block_storage_volumes()
216+
result = block_storage_tools.get_volumes()
217217

218218
assert isinstance(result, list)
219219
assert len(result) == 2
@@ -490,7 +490,7 @@ def test_delete_volume_success(self, mock_get_openstack_conn_block_storage):
490490
# Verify result is None
491491
assert result is None
492492
mock_conn.block_storage.delete_volume.assert_called_once_with(
493-
"vol-delete", force=False
493+
"vol-delete", force=False, ignore_missing=False
494494
)
495495

496496
def test_delete_volume_force(self, mock_get_openstack_conn_block_storage):
@@ -510,7 +510,7 @@ def test_delete_volume_force(self, mock_get_openstack_conn_block_storage):
510510
assert result is None
511511

512512
mock_conn.block_storage.delete_volume.assert_called_once_with(
513-
"vol-force-delete", force=True
513+
"vol-force-delete", force=True, ignore_missing=False
514514
)
515515

516516
def test_delete_volume_error(self, mock_get_openstack_conn_block_storage):
@@ -582,7 +582,7 @@ def test_register_tools(self):
582582
call[0][0] for call in mock_tool_decorator.call_args_list
583583
]
584584
expected_methods = [
585-
block_storage_tools.get_block_storage_volumes,
585+
block_storage_tools.get_volumes,
586586
block_storage_tools.get_volume_details,
587587
block_storage_tools.create_volume,
588588
block_storage_tools.delete_volume,
@@ -597,23 +597,23 @@ def test_block_storage_tools_instantiation(self):
597597
block_storage_tools = BlockStorageTools()
598598
assert block_storage_tools is not None
599599
assert hasattr(block_storage_tools, "register_tools")
600-
assert hasattr(block_storage_tools, "get_block_storage_volumes")
600+
assert hasattr(block_storage_tools, "get_volumes")
601601
assert hasattr(block_storage_tools, "get_volume_details")
602602
assert hasattr(block_storage_tools, "create_volume")
603603
assert hasattr(block_storage_tools, "delete_volume")
604604
assert hasattr(block_storage_tools, "extend_volume")
605605
# Verify all methods are callable
606606
assert callable(block_storage_tools.register_tools)
607-
assert callable(block_storage_tools.get_block_storage_volumes)
607+
assert callable(block_storage_tools.get_volumes)
608608
assert callable(block_storage_tools.get_volume_details)
609609
assert callable(block_storage_tools.create_volume)
610610
assert callable(block_storage_tools.delete_volume)
611611
assert callable(block_storage_tools.extend_volume)
612612

613-
def test_get_block_storage_volumes_docstring(self):
614-
"""Test that get_block_storage_volumes has proper docstring."""
613+
def test_get_volumes_docstring(self):
614+
"""Test that get_volumes has proper docstring."""
615615
block_storage_tools = BlockStorageTools()
616-
docstring = block_storage_tools.get_block_storage_volumes.__doc__
616+
docstring = block_storage_tools.get_volumes.__doc__
617617

618618
assert docstring is not None
619619
assert "Get the list of Block Storage volumes" in docstring
@@ -628,7 +628,7 @@ def test_all_block_storage_methods_have_docstrings(self):
628628
block_storage_tools = BlockStorageTools()
629629

630630
methods_to_check = [
631-
"get_block_storage_volumes",
631+
"get_volumes",
632632
"get_volume_details",
633633
"create_volume",
634634
"delete_volume",

0 commit comments

Comments
 (0)