From 5f656ad03acffe6510808826e85572303c05bfce Mon Sep 17 00:00:00 2001 From: hallvictoria <59299039+hallvictoria@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:18:43 -0500 Subject: [PATCH] fix: allow source to be string and enum (#256) * allowing both BlobSource and string source values * add test * using isinstance, removed extra if check * mypy fix --------- Co-authored-by: Victoria Hall --- azure/functions/decorators/blob.py | 5 ++++- tests/decorators/test_blob.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/azure/functions/decorators/blob.py b/azure/functions/decorators/blob.py index bd2861fa..9ed4ce2f 100644 --- a/azure/functions/decorators/blob.py +++ b/azure/functions/decorators/blob.py @@ -17,7 +17,10 @@ def __init__(self, **kwargs): self.path = path self.connection = connection - self.source = source.value if source else None + if isinstance(source, BlobSource): + self.source = source.value + else: + self.source = source # type: ignore super().__init__(name=name, data_type=data_type) @staticmethod diff --git a/tests/decorators/test_blob.py b/tests/decorators/test_blob.py index 43926591..bad8f99b 100644 --- a/tests/decorators/test_blob.py +++ b/tests/decorators/test_blob.py @@ -50,7 +50,7 @@ def test_blob_trigger_creation_with_source_as_string(self): trigger = BlobTrigger(name="req", path="dummy_path", connection="dummy_connection", - source=BlobSource.EVENT_GRID, + source="EventGrid", data_type=DataType.UNDEFINED, dummy_field="dummy")