@@ -741,3 +741,45 @@ 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+ mock_attachment .connection_info = None
756+ mock_attachment .connector = None
757+ mock_attachment .attach_mode = None
758+ mock_attachment .attached_at = None
759+ mock_attachment .detached_at = None
760+
761+ mock_conn .block_storage .attachments .return_value = [mock_attachment ]
762+
763+ # Test attachments
764+ block_storage_tools = BlockStorageTools ()
765+
766+ filter = {
767+ "volume_id" : "vol-123" ,
768+ "instance" : "server-123" ,
769+ }
770+ result = block_storage_tools .get_attachments (** filter )
771+
772+ # Verify the result
773+ assert isinstance (result , list )
774+ assert len (result ) == 1
775+ assert result [0 ].id == "attach-123"
776+ assert result [0 ].instance == "server-123"
777+ assert result [0 ].volume_id == "vol-123"
778+ assert result [0 ].attached_at is None
779+ assert result [0 ].detached_at is None
780+ assert result [0 ].attach_mode is None
781+ assert result [0 ].connection_info is None
782+ assert result [0 ].connector is None
783+
784+ # Verify the mock calls
785+ mock_conn .block_storage .attachments .assert_called_once_with (** filter )
0 commit comments