@@ -616,7 +616,7 @@ def test_register_tools(self):
616616 block_storage_tools .register_tools (mock_mcp )
617617
618618 # Verify mcp.tool() was called for each method
619- assert mock_mcp .tool .call_count == 6
619+ assert mock_mcp .tool .call_count == 7
620620
621621 # Verify all methods were registered
622622 registered_methods = [
@@ -744,3 +744,36 @@ def test_get_attachment_details(
744744 mock_conn .block_storage .get_attachment .assert_called_once_with (
745745 "attach-123"
746746 )
747+
748+ def test_get_attachments (self , mock_get_openstack_conn_block_storage ):
749+ """Test getting attachments."""
750+ mock_conn = mock_get_openstack_conn_block_storage
751+
752+ # Create mock attachment object
753+ mock_attachment = Mock ()
754+ mock_attachment .id = "attach-123"
755+ mock_attachment .instance = "server-123"
756+ mock_attachment .volume_id = "vol-123"
757+ mock_attachment .status = "attached"
758+
759+ mock_conn .block_storage .attachments .return_value = [mock_attachment ]
760+
761+ # Test attachments
762+ block_storage_tools = BlockStorageTools ()
763+
764+ filter = {
765+ "volume_id" : "vol-123" ,
766+ "instance" : "server-123" ,
767+ }
768+ result = block_storage_tools .get_attachments (** filter )
769+
770+ # Verify the result
771+ assert isinstance (result , list )
772+ assert len (result ) == 1
773+ assert result [0 ].id == "attach-123"
774+ assert result [0 ].instance == "server-123"
775+ assert result [0 ].volume_id == "vol-123"
776+ assert result [0 ].status == "attached"
777+
778+ # Verify the mock calls
779+ mock_conn .block_storage .attachments .assert_called_once_with (** filter )
0 commit comments