Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional source param for blob trigger #220

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure/functions/decorators/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self,
name: str,
path: str,
connection: str,
source: BlobSource,
source: Optional[BlobSource] = None,
data_type: Optional[DataType] = None,
**kwargs):
self.path = path
Expand Down
4 changes: 2 additions & 2 deletions azure/functions/decorators/function_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,8 @@ def blob_trigger(self,
arg_name: str,
path: str,
connection: str,
source: BlobSource =
BlobSource.LOGS_AND_CONTAINER_SCAN,
source: Optional[BlobSource] =
None,
data_type: Optional[DataType] = None,
**kwargs) -> Callable[..., Any]:
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/ProgModelSpec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class TriggerApi(DecoratorApi, ABC):
arg_name: str,
path: str,
connection: str,
source: BlobSource = BlobSource.LOGS_AND_CONTAINER_SCAN,
source: Optional[BlobSource] = None,
data_type: Optional[DataType] = None,
**kwargs) -> Callable:
"""
Expand Down
38 changes: 38 additions & 0 deletions tests/decorators/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,44 @@


class TestBlob(unittest.TestCase):
def test_blob_trigger_creation_with_no_source(self):
trigger = BlobTrigger(name="req",
path="dummy_path",
connection="dummy_connection",
data_type=DataType.UNDEFINED,
dummy_field="dummy")

self.assertEqual(trigger.get_binding_name(), "blobTrigger")
self.assertEqual(trigger.get_dict_repr(), {
"type": "blobTrigger",
"direction": BindingDirection.IN,
'dummyField': 'dummy',
"name": "req",
"dataType": DataType.UNDEFINED,
"path": "dummy_path",
"connection": "dummy_connection"
})

def test_blob_trigger_creation_with_default_specified_source(self):
trigger = BlobTrigger(name="req",
path="dummy_path",
connection="dummy_connection",
source=BlobSource.LOGS_AND_CONTAINER_SCAN,
data_type=DataType.UNDEFINED,
dummy_field="dummy")

self.assertEqual(trigger.get_binding_name(), "blobTrigger")
self.assertEqual(trigger.get_dict_repr(), {
"type": "blobTrigger",
"direction": BindingDirection.IN,
'dummyField': 'dummy',
"name": "req",
"dataType": DataType.UNDEFINED,
"path": "dummy_path",
'source': BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_connection"
})

def test_blob_trigger_creation_with_source_as_string(self):
trigger = BlobTrigger(name="req",
path="dummy_path",
Expand Down
4 changes: 0 additions & 4 deletions tests/decorators/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,6 @@ def dummy():
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source":
BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
}]})

Expand All @@ -1595,7 +1593,6 @@ def dummy():
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source": BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
})

Expand Down Expand Up @@ -1665,7 +1662,6 @@ def dummy():
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source": BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
})

Expand Down
Loading