@@ -741,3 +741,36 @@ def test_get_attachment_details(
741741 mock_conn .block_storage .get_attachment .assert_called_once_with (
742742 "attach-123"
743743 )
744+
745+ def test_get_attachments (self , mock_get_openstack_conn_block_storage ):
746+ """Test getting attachments."""
747+ mock_conn = mock_get_openstack_conn_block_storage
748+
749+ # Create mock attachment object
750+ mock_attachment = Mock ()
751+ mock_attachment .id = "attach-123"
752+ mock_attachment .instance = "server-123"
753+ mock_attachment .volume_id = "vol-123"
754+ mock_attachment .status = "attached"
755+
756+ mock_conn .block_storage .attachments .return_value = [mock_attachment ]
757+
758+ # Test attachments
759+ block_storage_tools = BlockStorageTools ()
760+
761+ filter = {
762+ "volume_id" : "vol-123" ,
763+ "instance" : "server-123" ,
764+ }
765+ result = block_storage_tools .get_attachments (** filter )
766+
767+ # Verify the result
768+ assert isinstance (result , list )
769+ assert len (result ) == 1
770+ assert result [0 ].id == "attach-123"
771+ assert result [0 ].instance == "server-123"
772+ assert result [0 ].volume_id == "vol-123"
773+ assert result [0 ].status == "attached"
774+
775+ # Verify the mock calls
776+ mock_conn .block_storage .attachments .assert_called_once_with (** filter )
0 commit comments