Пример #1
0
    def test_download_file(self, client):
        client.return_value.walk_blobs.return_value = MockBlobList([])

        dirname = tempfile.mkdtemp()
        fpath = dirname + "/test.txt"

        def mkfile(buffer):
            return open(buffer.name, "w")

        client.get_container_client().download_blob().readinto.side_effect = mkfile

        base_path = "path/test.txt"
        store = AzureBlobStoreService()
        store.set_connection(connection=client)
        key_path = self.wasbs_base + base_path

        # Test without basename
        store.download_file(key_path, fpath, use_basename=False)
        client.get_container_client().download_blob.assert_called_with(base_path)
        assert os.path.exists(fpath)

        # Test without basename
        store.download_file(key_path, dirname, use_basename=True)
        client.get_container_client().download_blob.assert_called_with(base_path)
        assert os.path.exists(fpath)
Пример #2
0
    def test_download_file(self, client):
        client.return_value.list_blobs.return_value = MockBlobList([])

        dirname = tempfile.mkdtemp()
        fpath = dirname + "/test.txt"

        def mkfile(container, cloud_path, fname):
            return open(fname, "w")

        client.return_value.get_blob_to_path.side_effect = mkfile

        base_path = "path/test.txt"
        store = AzureBlobStoreService()
        key_path = self.wasbs_base + base_path

        # Test without basename
        store.download_file(key_path, fpath, use_basename=False)
        client.return_value.get_blob_to_path.assert_called_with(
            "container", base_path, fpath
        )

        # Test without basename
        store.download_file(key_path, dirname, use_basename=True)
        client.return_value.get_blob_to_path.assert_called_with(
            "container", base_path, fpath
        )