зеркало из
1
0
Форкнуть 0

Optional source param for blob trigger (#220)

* making source optional param

* fixed tests

* added tests
This commit is contained in:
hallvictoria 2024-05-30 11:43:20 -05:00 коммит произвёл GitHub
Родитель 3e87e81797
Коммит bdeb2c2e29
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 42 добавлений и 8 удалений

Просмотреть файл

@ -12,7 +12,7 @@ class BlobTrigger(Trigger):
name: str,
path: str,
connection: str,
source: BlobSource,
source: Optional[BlobSource] = None,
data_type: Optional[DataType] = None,
**kwargs):
self.path = path

Просмотреть файл

@ -1114,8 +1114,8 @@ 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[..., Any]:
"""

Просмотреть файл

@ -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:
"""

Просмотреть файл

@ -8,6 +8,44 @@ from azure.functions.decorators.core import BindingDirection, BlobSource, \
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",

Просмотреть файл

@ -1569,8 +1569,6 @@ class TestFunctionsApp(unittest.TestCase):
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source":
BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
}]})
@ -1595,7 +1593,6 @@ class TestFunctionsApp(unittest.TestCase):
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source": BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
})
@ -1665,7 +1662,6 @@ class TestFunctionsApp(unittest.TestCase):
"type": BLOB_TRIGGER,
"name": "req",
"path": "dummy_path",
"source": BlobSource.LOGS_AND_CONTAINER_SCAN,
"connection": "dummy_conn"
})