-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/azure_data_factory_testing_framework/models/activities/fail_activity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Any | ||
|
||
from azure_data_factory_testing_framework.models.activities.control_activity import ControlActivity | ||
from azure_data_factory_testing_framework.state import PipelineRunState | ||
from azure_data_factory_testing_framework.state.dependency_condition import DependencyCondition | ||
|
||
|
||
class FailActivity(ControlActivity): | ||
def __init__(self, **kwargs: Any) -> None: # noqa: ANN401 | ||
"""This is the class that represents the Fail activity in the pipeline. | ||
Args: | ||
**kwargs: FailActivity properties coming directly from the json representation of the activity. | ||
""" | ||
kwargs["type"] = "Fail" | ||
|
||
super(ControlActivity, self).__init__(**kwargs) | ||
|
||
def evaluate(self, state: PipelineRunState) -> "FailActivity": | ||
super(ControlActivity, self).evaluate(state) | ||
|
||
self.set_result(DependencyCondition.FAILED) | ||
|
||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from azure_data_factory_testing_framework.models.activities.fail_activity import FailActivity | ||
from azure_data_factory_testing_framework.models.data_factory_element import DataFactoryElement | ||
from azure_data_factory_testing_framework.state import PipelineRunState | ||
from azure_data_factory_testing_framework.state.dependency_condition import DependencyCondition | ||
|
||
|
||
def test_fail_activity_evaluates_to_failed_result() -> None: | ||
# Arrange | ||
fail_activity = FailActivity( | ||
name="FailActivity", | ||
typeProperties={ | ||
"message": DataFactoryElement("concat('Error code: ', '500')"), | ||
"errorCode": "500", | ||
}, | ||
depends_on=[], | ||
) | ||
|
||
state = PipelineRunState() | ||
|
||
# Act | ||
activity = fail_activity.evaluate(state) | ||
|
||
# Assert | ||
assert activity is not None | ||
assert activity.name == "FailActivity" | ||
assert activity.status == DependencyCondition.FAILED | ||
assert activity.type_properties["message"].value == "Error code: 500" | ||
assert activity.type_properties["errorCode"] == "500" |