Ejemplo n.º 1
0
    def test_read_container_extract(self, mock_copy, mock_ip, mock_storage_obj,
                                    mock_extract):
        disk_storage_backend = DiskStorageBackend()
        full_path_to_src = "the/full/path/to/src"
        container_path = "container/path"

        mock_storage_obj.container = True
        mock_storage_obj.get_full_path.return_value = full_path_to_src
        mock_storage_obj.storage_medium.storage_target.target = container_path
        mock_storage_obj.ip = mock_ip
        mock_ip.aic.pk = 1234

        disk_storage_backend.read(storage_object=mock_storage_obj,
                                  dst="some_dest",
                                  extract=True)

        expected_copy_calls = [
            mock.call(f"{full_path_to_src}.xml", "some_dest",
                      block_size=65536),
            mock.call(os.path.join(container_path, "1234.xml"),
                      "some_dest",
                      block_size=65536),
        ]

        self.assertEqual(mock_copy.call_count, 2)
        mock_copy.assert_has_calls(expected_copy_calls)
        mock_extract.assert_called_once_with(mock_storage_obj, "some_dest")
Ejemplo n.º 2
0
    def test_read_container_default(self, mock_copy, mock_ip,
                                    mock_storage_obj):
        disk_storage_backend = DiskStorageBackend()
        full_path_to_src = "the/full/path/to/src"
        container_path = "container/path"

        mock_storage_obj.container = True
        mock_storage_obj.get_full_path.return_value = full_path_to_src
        mock_storage_obj.storage_medium.storage_target.target = container_path
        mock_storage_obj.ip = mock_ip
        mock_ip.aic.pk = 1234

        disk_storage_backend.read(storage_object=mock_storage_obj,
                                  dst="some_dest")

        expected_copy_calls = [
            mock.call(f"{full_path_to_src}.xml",
                      "some_dest",
                      block_size=DEFAULT_BLOCK_SIZE),
            mock.call(os.path.join(container_path, "1234.xml"),
                      "some_dest",
                      block_size=DEFAULT_BLOCK_SIZE),
            mock.call(f"{full_path_to_src}",
                      "some_dest",
                      block_size=DEFAULT_BLOCK_SIZE)
        ]

        self.assertEqual(mock_copy.call_count, 3)
        mock_copy.assert_has_calls(expected_copy_calls)
Ejemplo n.º 3
0
    def test_read_not_container_should_call_copy(self, mock_copy,
                                                 mock_storage_obj):
        disk_storage_backend = DiskStorageBackend()

        mock_storage_obj.container = False
        mock_storage_obj.get_full_path.return_value = "the_full_path"

        disk_storage_backend.read(storage_object=mock_storage_obj,
                                  dst="some_dest")

        mock_copy.assert_called_once_with("the_full_path",
                                          "some_dest",
                                          block_size=65536)
Ejemplo n.º 4
0
    def test_read_container_no_xml(self, mock_copy, mock_ip, mock_storage_obj):
        disk_storage_backend = DiskStorageBackend()
        full_path_to_src = "the/full/path/to/src"
        container_path = "container/path"

        mock_storage_obj.container = True
        mock_storage_obj.get_full_path.return_value = full_path_to_src
        mock_storage_obj.storage_medium.storage_target.target = container_path
        mock_storage_obj.ip = mock_ip
        mock_ip.aic.pk = 1234

        disk_storage_backend.read(storage_object=mock_storage_obj,
                                  dst="some_dest",
                                  include_xml=False)

        mock_copy.assert_called_once_with(f"{full_path_to_src}",
                                          "some_dest",
                                          block_size=65536)