コード例 #1
0
    def test_upload_file(self, client):
        dirname = tempfile.mkdtemp()
        fpath = dirname + "/test.txt"
        open(fpath, "w")

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

        # Test without basename
        key_path = self.wasbs_base + base_path_file
        store.upload_file(filename=fpath, blob=key_path, use_basename=False)
        call_arg1, call_arg2 = client.get_container_client(
        ).upload_blob.call_args[0]
        assert call_arg1 == base_path_file
        assert call_arg2.name == fpath

        # Test with basename
        key_path = self.wasbs_base + base_path
        store.upload_file(filename=fpath, blob=key_path, use_basename=True)
        call_arg1, call_arg2 = client.get_container_client(
        ).upload_blob.call_args[0]
        assert call_arg1 == base_path_file
        assert call_arg2.name == fpath
コード例 #2
0
ファイル: test_azure_store.py プロジェクト: savvihub/polyaxon
    def test_upload_file(self, client):
        dirname = tempfile.mkdtemp()
        fpath = dirname + "/test.txt"
        open(fpath, "w")

        base_path = "path/"
        base_path_file = base_path + "test.txt"
        store = AzureBlobStoreService()

        # Test without basename
        key_path = self.wasbs_base + base_path_file
        store.upload_file(filename=fpath, blob=key_path, use_basename=False)
        client.return_value.create_blob_from_path.assert_called_with(
            "container", base_path_file, fpath
        )

        # Test with basename
        key_path = self.wasbs_base + base_path
        store.upload_file(filename=fpath, blob=key_path, use_basename=True)
        client.return_value.create_blob_from_path.assert_called_with(
            "container", base_path_file, fpath
        )