From d415bd9de298abb4a20c18488e4e9cda31e978cd Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Thu, 8 May 2025 16:09:23 +0200 Subject: [PATCH 1/3] feat: add the option to add an error to an ActivityResult --- .../data_factory_testing_framework_expressions_evaluator.py | 1 + src/data_factory_testing_framework/state/_activity_result.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py b/src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py index 8bcf7e64..f592f77e 100644 --- a/src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py +++ b/src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py @@ -42,6 +42,7 @@ def evaluate(expression: str, state: PipelineRunState) -> Union[str, int, float, "body": { "output": activity.output, "status": activity.status, + "error": activity.error, } } } diff --git a/src/data_factory_testing_framework/state/_activity_result.py b/src/data_factory_testing_framework/state/_activity_result.py index 040687b7..5fe96af5 100644 --- a/src/data_factory_testing_framework/state/_activity_result.py +++ b/src/data_factory_testing_framework/state/_activity_result.py @@ -9,6 +9,7 @@ def __init__( activity_name: str, status: Optional[DependencyCondition] = None, output: Optional[Any] = None, # noqa: ANN401 + error: Optional[Any] = None, # noqa: ANN401 ) -> None: """Represents the result of an activity. @@ -16,10 +17,12 @@ def __init__( activity_name: Name of the activity. status: Status of the activity. output: Output of the activity. (e.g. { "count": 1 } for activity('activityName').output.count) + error: Error of the activity. (e.g. { "code": "ErrorCode", "message": "ErrorMessage" } for activity('activityName').Error) """ self.activity_name = activity_name self.status = status if status is not None else DependencyCondition.SUCCEEDED self.output = output + self.error = error def __getitem__(self, item: str) -> Any: # noqa: ANN401 return getattr(self, item) From cc1f2ea12fe8ca3c0ad9f968d18f87829a839b0f Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Fri, 9 May 2025 10:38:43 +0200 Subject: [PATCH 2/3] docs: clarify requirements for development --- DEVELOPMENT.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 29d9ed29..0fc0f928 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -6,6 +6,14 @@ * poetry == 1.6.1 +### Installing the project + +Make sure to create a virtual environment and install the requirements by running: +`poetry install --with dev` + +Build the .NET project: +`dotnet build` + ### Pre-Commit Hooks We use pre-commit hooks to ensure that the code is formatted correctly and that the code is linted before committing. From ba61ff2db688427812dd2ae44d39adac66a36d5e Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Fri, 9 May 2025 10:39:36 +0200 Subject: [PATCH 3/3] test: add unit test for a failed ActivityResult --- ...tory_testing_framework_expression_evaluator.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/functions/test_data_factory_testing_framework_expression_evaluator.py b/tests/unit/functions/test_data_factory_testing_framework_expression_evaluator.py index e88c0b7a..08f59bd8 100644 --- a/tests/unit/functions/test_data_factory_testing_framework_expression_evaluator.py +++ b/tests/unit/functions/test_data_factory_testing_framework_expression_evaluator.py @@ -390,6 +390,21 @@ "value1", id="activity_reference_with_nested_property_and_string_reference", ), + p( + "@activity('Error activity').Error.message", + PipelineRunState( + activity_results=[ + ActivityResult( + activity_name="Error activity", + status=DependencyCondition.FAILED, + error={"message": "Oh no, something went wrong"}, + ) + ], + ), + "@activity('Error activity').Error.message", + "Oh no, something went wrong", + id="activity_reference_with_error_message", + ), ], ) def test_evaluate(