Skip to content

Commit d72a73c

Browse files
MarvinSchenkelMarvin Schenkel
and
Marvin Schenkel
authored
feat: add the option to add an error to an ActivityResult (#155)
* feat: add the option to add an error to an ActivityResult * docs: clarify requirements for development * test: add unit test for a failed ActivityResult --------- Co-authored-by: Marvin Schenkel <marvin.schenkel@nn-group.com>
1 parent 0315a3a commit d72a73c

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

DEVELOPMENT.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
* poetry == 1.6.1
88

9+
### Installing the project
10+
11+
Make sure to create a virtual environment and install the requirements by running:
12+
`poetry install --with dev`
13+
14+
Build the .NET project:
15+
`dotnet build`
16+
917
### Pre-Commit Hooks
1018

1119
We use pre-commit hooks to ensure that the code is formatted correctly and that the code is linted before committing.

src/data_factory_testing_framework/_pythonnet/data_factory_testing_framework_expressions_evaluator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def evaluate(expression: str, state: PipelineRunState) -> Union[str, int, float,
4242
"body": {
4343
"output": activity.output,
4444
"status": activity.status,
45+
"error": activity.error,
4546
}
4647
}
4748
}

src/data_factory_testing_framework/state/_activity_result.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ def __init__(
99
activity_name: str,
1010
status: Optional[DependencyCondition] = None,
1111
output: Optional[Any] = None, # noqa: ANN401
12+
error: Optional[Any] = None, # noqa: ANN401
1213
) -> None:
1314
"""Represents the result of an activity.
1415
1516
Args:
1617
activity_name: Name of the activity.
1718
status: Status of the activity.
1819
output: Output of the activity. (e.g. { "count": 1 } for activity('activityName').output.count)
20+
error: Error of the activity. (e.g. { "code": "ErrorCode", "message": "ErrorMessage" } for activity('activityName').Error)
1921
"""
2022
self.activity_name = activity_name
2123
self.status = status if status is not None else DependencyCondition.SUCCEEDED
2224
self.output = output
25+
self.error = error
2326

2427
def __getitem__(self, item: str) -> Any: # noqa: ANN401
2528
return getattr(self, item)

tests/unit/functions/test_data_factory_testing_framework_expression_evaluator.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,21 @@
390390
"value1",
391391
id="activity_reference_with_nested_property_and_string_reference",
392392
),
393+
p(
394+
"@activity('Error activity').Error.message",
395+
PipelineRunState(
396+
activity_results=[
397+
ActivityResult(
398+
activity_name="Error activity",
399+
status=DependencyCondition.FAILED,
400+
error={"message": "Oh no, something went wrong"},
401+
)
402+
],
403+
),
404+
"@activity('Error activity').Error.message",
405+
"Oh no, something went wrong",
406+
id="activity_reference_with_error_message",
407+
),
393408
],
394409
)
395410
def test_evaluate(

0 commit comments

Comments
 (0)