Beispiel #1
0
 def test_sas_token_creds_are_pulled_from_secret(self, monkeypatch):
     task = BlobStorageDownload(container="bob")
     service = MagicMock()
     blob = MagicMock(BlockBlobService=service)
     monkeypatch.setattr("prefect.tasks.azure.blobstorage.azure.storage.blob", blob)
     with set_temporary_config({"cloud.use_local_secrets": True}):
         with prefect.context(
             secrets=dict(AZ_CREDENTIALS={"ACCOUNT_NAME": "42", "SAS_TOKEN": "99"})
         ):
             task.run(blob_name="")
     kwargs = service.call_args[1]
     assert kwargs == {"account_name": "42", "sas_token": "99", "account_key": None}
Beispiel #2
0
    def test_connection_string_creds_are_pulled_from_secret_and_runs(
            self, monkeypatch):
        task = BlobStorageDownload(container="bob")

        client = MagicMock(download_blob=MagicMock())
        service = MagicMock(get_blob_client=MagicMock(return_value=client))
        blob = MagicMock(BlockBlobService=MagicMock(service))
        monkeypatch.setattr(
            "prefect.tasks.azure.blobstorage.azure.storage.blob", blob)

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(AZ_CONNECTION_STRING="conn")):
                task.run(blob_name="")
Beispiel #3
0
 def test_raises_if_container_not_eventually_provided(self):
     task = BlobStorageDownload()
     with pytest.raises(ValueError, match="container"):
         task.run(blob_name="")
Beispiel #4
0
 def test_initialization_passes_to_task_constructor(self):
     task = BlobStorageDownload(name="test", tags=["Azure"])
     assert task.name == "test"
     assert task.tags == {"Azure"}
Beispiel #5
0
 def test_initialization(self):
     task = BlobStorageDownload()
     assert task.azure_credentials_secret == "AZ_CONNECTION_STRING"
Beispiel #6
0
 def test_initialization(self):
     task = BlobStorageDownload()
     assert task.azure_credentials_secret == "AZ_CREDENTIALS"