Skip to content

Commit

Permalink
refactor: clean up model constructor arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
arjendev committed Nov 20, 2023
1 parent ac48920 commit 323374d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@


class Activity:
def __init__(self, **kwargs: Any) -> None: # noqa: ANN401
def __init__(self, name: str, type: str, policy: dict = None, **kwargs: Any) -> None: # noqa: ANN401, A002
"""Activity with dynamic dicts.
Args:
name: Name of the activity.
type: Type of the activity.
policy: Policy of the activity.
**kwargs: Activity properties coming directly from the json representation of the activity.
"""
self.name = kwargs["name"]
self.type = kwargs["type"]
if policy is None:
policy = {}

self.name = name
self.type = type
self.policy = policy
self.type_properties = kwargs["typeProperties"] if "typeProperties" in kwargs else {}

self.depends_on: List[ActivityDependency] = []
if "dependsOn" in kwargs:
for dependency in kwargs["dependsOn"]:
self.depends_on.append(ActivityDependency(**dependency))

self.policy = kwargs["policy"] if "policy" in kwargs else {}
self.type_properties = kwargs["typeProperties"] if "typeProperties" in kwargs else {}
self.all_properties = kwargs

self.status: DependencyCondition = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from typing import Any, List, Union
from typing import List, Union

from azure_data_factory_testing_framework.state.dependency_condition import DependencyCondition


class ActivityDependency:
def __init__(self, **kwargs: Any) -> None: # noqa: ANN401
def __init__(self, activity: str, dependencyConditions: List[Union[str, DependencyCondition]] = None) -> None: # noqa: ANN401, N803
"""ActivityDependency.
Args:
**kwargs: ActivityDependency properties coming directly from the json representation of the activity.
activity: Name of the activity.
dependencyConditions: List of dependency conditions.
"""
self.kwargs = kwargs
self.activity: str = kwargs["activity"]
self.dependency_conditions: List[Union[str, DependencyCondition]] = kwargs["dependencyConditions"]
if dependencyConditions is None:
dependencyConditions = [] # noqa: N806

self.activity: str = activity
self.dependency_conditions: List[DependencyCondition] = dependencyConditions
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def __init__(self, **kwargs: Any) -> None: # noqa: ANN401
Args:
**kwargs: ExecutePipelineActivity properties coming directly from the json representation of the activity.
"""
if "type" not in kwargs:
kwargs["type"] = "ExecutePipeline"
kwargs["type"] = "ExecutePipeline"

super(ControlActivity, self).__init__(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __init__(
activities: The deserialized activities that will be executed for each item in the items array.
**kwargs: ForEachActivity properties coming directly from the json representation of the activity.
"""
if "type" not in kwargs:
kwargs["type"] = "ForEach"
kwargs["type"] = "ForEach"

super(ControlActivity, self).__init__(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def __init__(
if_false_activities: The deserialized activities that will be executed if the condition is false.
**kwargs: IfConditionActivity properties coming directly from the json representation of the activity.
"""
if "type" not in kwargs:
kwargs["type"] = "IfCondition"
kwargs["type"] = "IfCondition"

super(ControlActivity, self).__init__(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def __init__(self, **kwargs: Any) -> None: # noqa: ANN401
Args:
**kwargs: SetVariableActivity properties coming directly from the json representation of the activity.
"""
if "type" not in kwargs:
kwargs["type"] = "SetVariable"
kwargs["type"] = "SetVariable"

super(ControlActivity, self).__init__(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __init__(
activities: The deserialized activities that will be executed until the expression evaluates to true.
**kwargs: UntilActivity properties coming directly from the json representation of the activity.
"""
if "type" not in kwargs:
kwargs["type"] = "Until"
kwargs["type"] = "Until"

super(ControlActivity, self).__init__(**kwargs)

Expand Down

0 comments on commit 323374d

Please sign in to comment.