Пример #1
0
    def test_register_call_uses_account_key(self, mock_workspace, monkeypatch):
        container_name = "my_container"
        task = DatastoreRegisterBlobContainer(workspace=mock_workspace)

        datastore_class = MagicMock()
        monkeypatch.setattr(
            "prefect.tasks.azureml.datastore.azureml.core.datastore.Datastore",
            datastore_class,
        )

        with set_temporary_config({"cloud.use_local_secrets": True}):
            with prefect.context(secrets=dict(AZ_CREDENTIALS={
                    "ACCOUNT_NAME": "42",
                    "ACCOUNT_KEY": "99"
            })):
                task.run(container_name=container_name)

        assert (datastore_class.register_azure_blob_container.call_args[1]
                ["account_key"] == "99")
Пример #2
0
    def test_missing_container_name_raises_error(self, mock_workspace):
        task = DatastoreRegisterBlobContainer(workspace=mock_workspace)

        with pytest.raises(ValueError,
                           match="A container name must be provided."):
            task.run()