Skip to content
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 providers/microsoft/azure/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PIP package Version required
``azure-synapse-artifacts`` ``>=0.17.0``
``azure-storage-file-datalake`` ``>=12.9.1``
``azure-kusto-data`` ``>=4.1.0,!=5.0.0``
``azure-mgmt-datafactory`` ``>=2.0.0``
``azure-mgmt-datafactory`` ``>=10.0.0``
``azure-mgmt-containerregistry`` ``>=8.0.0``
``azure-mgmt-compute`` ``>=33.0.0``
``azure-mgmt-containerinstance`` ``>=10.1.0``
Expand Down
2 changes: 1 addition & 1 deletion providers/microsoft/azure/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ PIP package Version required
``azure-synapse-artifacts`` ``>=0.17.0``
``azure-storage-file-datalake`` ``>=12.9.1``
``azure-kusto-data`` ``>=4.1.0,!=5.0.0``
``azure-mgmt-datafactory`` ``>=2.0.0``
``azure-mgmt-datafactory`` ``>=10.0.0``
``azure-mgmt-containerregistry`` ``>=8.0.0``
``azure-mgmt-compute`` ``>=33.0.0``
``azure-mgmt-containerinstance`` ``>=10.1.0``
Expand Down
2 changes: 1 addition & 1 deletion providers/microsoft/azure/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies = [
"azure-storage-file-datalake>=12.9.1",
# azure-kusto-data 5.0.0 pins requests to a specific version which makes resolving dependencies harder
"azure-kusto-data>=4.1.0,!=5.0.0",
"azure-mgmt-datafactory>=2.0.0",
"azure-mgmt-datafactory>=10.0.0",
"azure-mgmt-containerregistry>=8.0.0",
"azure-mgmt-compute>=33.0.0",
"azure-mgmt-containerinstance>=10.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from functools import wraps
from typing import IO, TYPE_CHECKING, Any, TypeVar, cast

from azure.core import MatchConditions
from azure.identity import ClientSecretCredential, DefaultAzureCredential
from azure.identity.aio import (
ClientSecretCredential as AsyncClientSecretCredential,
Expand Down Expand Up @@ -278,7 +279,12 @@ def update_factory(
raise AirflowException(f"Factory {factory!r} does not exist.")

return self.get_conn().factories.create_or_update(
resource_group_name, factory_name, factory, if_match, **config
resource_group_name,
factory_name,
factory,
etag=if_match,
match_condition=MatchConditions.IfNotModified if if_match else None,
**config,
)

@provide_targeted_factory
Expand Down Expand Up @@ -339,7 +345,12 @@ def get_linked_service(
:return: The linked service.
"""
return self.get_conn().linked_services.get(
resource_group_name, factory_name, linked_service_name, if_none_match, **config
resource_group_name,
factory_name,
linked_service_name,
etag=if_none_match,
match_condition=MatchConditions.IfModified if if_none_match else None,
**config,
)

def _linked_service_exists(self, resource_group_name, factory_name, linked_service_name) -> bool:
Expand Down Expand Up @@ -549,7 +560,12 @@ def get_dataflow(
:return: The DataFlowResource.
"""
return self.get_conn().data_flows.get(
resource_group_name, factory_name, dataflow_name, if_none_match, **config
resource_group_name,
factory_name,
dataflow_name,
etag=if_none_match,
match_condition=MatchConditions.IfModified if if_none_match else None,
**config,
)

def _dataflow_exists(
Expand Down Expand Up @@ -597,7 +613,13 @@ def update_dataflow(
raise AirflowException(f"Dataflow {dataflow_name!r} does not exist.")

return self.get_conn().data_flows.create_or_update(
resource_group_name, factory_name, dataflow_name, dataflow, if_match, **config
resource_group_name,
factory_name,
dataflow_name,
dataflow,
etag=if_match,
match_condition=MatchConditions.IfNotModified if if_match else None,
**config,
)

@provide_targeted_factory
Expand Down Expand Up @@ -627,7 +649,13 @@ def create_dataflow(
raise AirflowException(f"Dataflow {dataflow_name!r} already exists.")

return self.get_conn().data_flows.create_or_update(
resource_group_name, factory_name, dataflow_name, dataflow, if_match, **config
resource_group_name,
factory_name,
dataflow_name,
dataflow,
etag=if_match,
match_condition=MatchConditions.IfNotModified if if_match else None,
**config,
)

@provide_targeted_factory
Expand Down Expand Up @@ -923,7 +951,13 @@ def update_trigger(
raise AirflowException(f"Trigger {trigger_name!r} does not exist.")

return self.get_conn().triggers.create_or_update(
resource_group_name, factory_name, trigger_name, trigger, if_match, **config
resource_group_name,
factory_name,
trigger_name,
trigger,
etag=if_match,
match_condition=MatchConditions.IfNotModified if if_match else None,
**config,
)

@provide_targeted_factory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from unittest.mock import MagicMock, PropertyMock, patch

import pytest
from azure.core import MatchConditions
from azure.mgmt.datafactory.aio import DataFactoryManagementClient

from airflow.models.connection import Connection
Expand Down Expand Up @@ -242,12 +243,18 @@ def test_create_factory(hook: AzureDataFactoryHook):
hook._conn.factories.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, MODEL)


def test_update_factory(hook: AzureDataFactoryHook):
@pytest.mark.parametrize(
("if_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfNotModified)],
)
def test_update_factory(hook: AzureDataFactoryHook, if_match, expected_match_condition):
with patch.object(hook, "_factory_exists") as mock_factory_exists:
mock_factory_exists.return_value = True
hook.update_factory(MODEL, RESOURCE_GROUP, FACTORY)
hook.update_factory(MODEL, RESOURCE_GROUP, FACTORY, if_match)

hook._conn.factories.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, MODEL, None)
hook._conn.factories.create_or_update.assert_called_with(
RESOURCE_GROUP, FACTORY, MODEL, etag=if_match, match_condition=expected_match_condition
)


def test_update_factory_non_existent(hook: AzureDataFactoryHook):
Expand All @@ -264,10 +271,16 @@ def test_delete_factory(hook: AzureDataFactoryHook):
hook._conn.factories.delete.assert_called_with(RESOURCE_GROUP, FACTORY)


def test_get_linked_service(hook: AzureDataFactoryHook):
hook.get_linked_service(NAME, RESOURCE_GROUP, FACTORY)
@pytest.mark.parametrize(
("if_none_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfModified)],
)
def test_get_linked_service(hook: AzureDataFactoryHook, if_none_match, expected_match_condition):
hook.get_linked_service(NAME, RESOURCE_GROUP, FACTORY, if_none_match)

hook._conn.linked_services.get.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, None)
hook._conn.linked_services.get.assert_called_with(
RESOURCE_GROUP, FACTORY, NAME, etag=if_none_match, match_condition=expected_match_condition
)


def test_create_linked_service(hook: AzureDataFactoryHook):
Expand Down Expand Up @@ -332,24 +345,42 @@ def test_delete_dataset(hook: AzureDataFactoryHook):
hook._conn.datasets.delete.assert_called_with(RESOURCE_GROUP, FACTORY, NAME)


def test_get_dataflow(hook: AzureDataFactoryHook):
hook.get_dataflow(NAME, RESOURCE_GROUP, FACTORY)
@pytest.mark.parametrize(
("if_none_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfModified)],
)
def test_get_dataflow(hook: AzureDataFactoryHook, if_none_match, expected_match_condition):
hook.get_dataflow(NAME, RESOURCE_GROUP, FACTORY, if_none_match)

hook._conn.data_flows.get.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, None)
hook._conn.data_flows.get.assert_called_with(
RESOURCE_GROUP, FACTORY, NAME, etag=if_none_match, match_condition=expected_match_condition
)


def test_create_dataflow(hook: AzureDataFactoryHook):
hook.create_dataflow(NAME, MODEL, RESOURCE_GROUP, FACTORY)
@pytest.mark.parametrize(
("if_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfNotModified)],
)
def test_create_dataflow(hook: AzureDataFactoryHook, if_match, expected_match_condition):
hook.create_dataflow(NAME, MODEL, RESOURCE_GROUP, FACTORY, if_match)

hook._conn.data_flows.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, MODEL, None)
hook._conn.data_flows.create_or_update.assert_called_with(
RESOURCE_GROUP, FACTORY, NAME, MODEL, etag=if_match, match_condition=expected_match_condition
)


def test_update_dataflow(hook: AzureDataFactoryHook):
@pytest.mark.parametrize(
("if_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfNotModified)],
)
def test_update_dataflow(hook: AzureDataFactoryHook, if_match, expected_match_condition):
with patch.object(hook, "_dataflow_exists") as mock_dataflow_exists:
mock_dataflow_exists.return_value = True
hook.update_dataflow(NAME, MODEL, RESOURCE_GROUP, FACTORY)
hook.update_dataflow(NAME, MODEL, RESOURCE_GROUP, FACTORY, if_match)

hook._conn.data_flows.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, MODEL, None)
hook._conn.data_flows.create_or_update.assert_called_with(
RESOURCE_GROUP, FACTORY, NAME, MODEL, etag=if_match, match_condition=expected_match_condition
)


def test_update_dataflow_non_existent(hook: AzureDataFactoryHook):
Expand Down Expand Up @@ -473,12 +504,18 @@ def test_create_trigger(hook: AzureDataFactoryHook):
hook._conn.triggers.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, MODEL)


def test_update_trigger(hook: AzureDataFactoryHook):
@pytest.mark.parametrize(
("if_match", "expected_match_condition"),
[(None, None), ("etag-value", MatchConditions.IfNotModified)],
)
def test_update_trigger(hook: AzureDataFactoryHook, if_match, expected_match_condition):
with patch.object(hook, "_trigger_exists") as mock_trigger_exists:
mock_trigger_exists.return_value = True
hook.update_trigger(NAME, MODEL, RESOURCE_GROUP, FACTORY)
hook.update_trigger(NAME, MODEL, RESOURCE_GROUP, FACTORY, if_match)

hook._conn.triggers.create_or_update.assert_called_with(RESOURCE_GROUP, FACTORY, NAME, MODEL, None)
hook._conn.triggers.create_or_update.assert_called_with(
RESOURCE_GROUP, FACTORY, NAME, MODEL, etag=if_match, match_condition=expected_match_condition
)


def test_update_trigger_non_existent(hook: AzureDataFactoryHook):
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.