Skip to content

Commit

Permalink
refactor: improve package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
arjendev committed Nov 15, 2023
1 parent 8f41d28 commit f7b807a
Show file tree
Hide file tree
Showing 48 changed files with 133 additions and 106 deletions.
11 changes: 11 additions & 0 deletions src/python/data_factory_testing_framework/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from data_factory_testing_framework.functions.function_argument import FunctionArgument
from data_factory_testing_framework.functions.function_call import FunctionCall
from data_factory_testing_framework.functions.function_parser import parse_expression
from data_factory_testing_framework.functions.functions_repository import FunctionsRepository

__all__ = [
"FunctionArgument",
"FunctionCall",
"parse_expression",
"FunctionsRepository",
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

from data_factory_testing_framework.exceptions.activity_not_found_error import ActivityNotFoundError
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_activity(expression: str, state: PipelineRunState) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import re

from data_factory_testing_framework.exceptions.dataset_parameter_not_found_error import DatasetParameterNotFoundError
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import RunParameterType
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_dataset(expression: str, state: PipelineRunState) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

from data_factory_testing_framework.exceptions.state_iteration_item_not_set_error import StateIterationItemNotSetError
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_iteration_item(expression: str, state: PipelineRunState) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from data_factory_testing_framework.exceptions.linked_service_parameter_not_found_error import (
LinkedServiceParameterNotFoundError,
)
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import RunParameterType
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_linked_services(expression: str, state: PipelineRunState) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from data_factory_testing_framework.exceptions.expression_parameter_not_found_error import (
ExpressionParameterNotFoundError,
)
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import RunParameterType
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_parameters(expression: str, parameter_type: RunParameterType, state: PipelineRunState) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

from data_factory_testing_framework.exceptions.variable_not_found_error import VariableNotFoundError
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


def find_and_replace_variables(expression: str, state: PipelineRunState) -> str:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from data_factory_testing_framework.functions.expressions.expression_activity import find_and_replace_activity
from data_factory_testing_framework.functions.expressions.expression_dataset import find_and_replace_dataset
from data_factory_testing_framework.functions.expressions.expression_iteration_item import (
from data_factory_testing_framework.functions._expression_activity import find_and_replace_activity
from data_factory_testing_framework.functions._expression_dataset import find_and_replace_dataset
from data_factory_testing_framework.functions._expression_iteration_item import (
find_and_replace_iteration_item,
)
from data_factory_testing_framework.functions.expressions.expression_linked_service import (
from data_factory_testing_framework.functions._expression_linked_service import (
find_and_replace_linked_services,
)
from data_factory_testing_framework.functions.expressions.expression_parameter import find_and_replace_parameters
from data_factory_testing_framework.functions.expressions.expression_variable import find_and_replace_variables
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.models.state.run_state import RunState
from data_factory_testing_framework.functions._expression_parameter import find_and_replace_parameters
from data_factory_testing_framework.functions._expression_variable import find_and_replace_variables
from data_factory_testing_framework.state import RunParameterType
from data_factory_testing_framework.state import PipelineRunState
from data_factory_testing_framework.state import RunState


def trim_one_char(text: str, character: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from data_factory_testing_framework.exceptions.unsupported_function_error import UnsupportedFunctionError
from data_factory_testing_framework.functions.function_argument import FunctionArgument
from data_factory_testing_framework.functions.functions_repository import FunctionsRepository
from data_factory_testing_framework.models.state.run_state import RunState
from data_factory_testing_framework.state import RunState


class FunctionCall:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import collections
import datetime
import sys
from abc import ABC
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union, Generator, Callable
from azure.mgmt.datafactory import _serialization

from .data_factory_element import DataFactoryElement
from ...models.state.run_state import RunState
from data_factory_testing_framework.generated.data_factory_element import DataFactoryElement

if sys.version_info >= (3, 9):
from collections.abc import MutableMapping
Expand Down Expand Up @@ -91,7 +88,7 @@ def __init__(self, *, name: str, additional_properties: Optional[Dict[str, JSON]
self.depends_on = depends_on
self.user_properties = user_properties

def evaluate(self, state: RunState) -> str:
def evaluate(self, state) -> str:
pass

class ActivityDependency(_serialization.Model):
Expand Down Expand Up @@ -2301,8 +2298,8 @@ def __init__(self, *, name: str, additional_properties: Optional[Dict[str, JSON]

def evaluate_control_activity_iterations(
self,
state: RunState,
evaluate_activities: Callable[[RunState], Generator[Activity, None, None]],
state,
evaluate_activities: Callable,
) -> Generator[Activity, None, None]:
return []

Expand Down
9 changes: 9 additions & 0 deletions src/python/data_factory_testing_framework/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from data_factory_testing_framework.models.repositories.data_factory_repository_factory import DataFactoryRepositoryFactory
from data_factory_testing_framework.models.repositories.data_factory_repository import DataFactoryRepository

__all__ = [
"DataFactoryRepositoryFactory",
"DataFactoryRepository",
]


Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from data_factory_testing_framework.generated import models as _models
from data_factory_testing_framework.models.activities.base import Activity
from data_factory_testing_framework.models.expressions._data_factory_element import DataFactoryElement
from data_factory_testing_framework.models.expressions._expression import Expression
from data_factory_testing_framework.models.activities.base.activity import Activity
from data_factory_testing_framework.models.activities.control_activities.execute_pipeline_activity import (
ExecutePipelineActivity,
)
Expand All @@ -9,8 +11,6 @@
)
from data_factory_testing_framework.models.activities.control_activities.until_activity import UntilActivity
from data_factory_testing_framework.models.activities.set_variable_activity import SetVariableActivity
from data_factory_testing_framework.models.data_factory_element import DataFactoryElement
from data_factory_testing_framework.models.expression import Expression
from data_factory_testing_framework.models.pipelines.pipeline_resource import PipelineResource


Expand Down
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from data_factory_testing_framework.generated.models import Activity, DataFactoryElement, DependencyCondition
from data_factory_testing_framework.generated.models import Activity as GeneratedActivity
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class Activity:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List

from data_factory_testing_framework.models.base.run_parameter import RunParameter
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state.run_parameter import RunParameter
from data_factory_testing_framework.state import RunParameterType
from data_factory_testing_framework.state import PipelineRunState


class ExecutePipelineActivity:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Callable, Generator

from data_factory_testing_framework.generated.models import Activity, ControlActivity, ForEachActivity
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class ForEachActivity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ControlActivity,
IfConditionActivity,
)
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class IfConditionActivity:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Callable, Generator

from data_factory_testing_framework.generated.models import Activity, ControlActivity, UntilActivity
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class UntilActivity:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from data_factory_testing_framework.generated.models import ControlActivity, SetVariableActivity
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class SetVariableActivity:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Union, Generic, TypeVar

from data_factory_testing_framework.functions import parse_expression
from data_factory_testing_framework.generated.models import DataFactoryElement
from data_factory_testing_framework.state import RunState

T = TypeVar("T")


class DataFactoryElement(Generic[T]):
def __init__(self) -> None:
"""DataFactoryElement."""
self.value: Union[str, int, bool] = None

def evaluate(self: DataFactoryElement, state: RunState) -> Union[str, int, bool]:
self.value = parse_expression(self.expression).evaluate(state)
return self.value
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from data_factory_testing_framework.functions.function_parser import parse_expression
from data_factory_testing_framework.generated.models import Expression
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState
from data_factory_testing_framework.state import PipelineRunState


class Expression:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from data_factory_testing_framework.exceptions.activity_not_found_error import ActivityNotFoundError
from data_factory_testing_framework.generated.models import Activity, PipelineResource
from data_factory_testing_framework.models.base.run_parameter import RunParameter
from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.state.run_parameter import RunParameter
from data_factory_testing_framework.state import RunParameterType


class PipelineResource:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from data_factory_testing_framework.generated import Deserializer
from data_factory_testing_framework.generated import models as _models
from data_factory_testing_framework.models.patch_models import patch_models
from data_factory_testing_framework.models._patch_models import patch_models
from data_factory_testing_framework.models.repositories.data_factory_repository import DataFactoryRepository

patch_models()
Expand Down
Empty file.
Empty file.
13 changes: 13 additions & 0 deletions src/python/data_factory_testing_framework/state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .pipeline_run_state import PipelineRunState
from .pipeline_run_variable import PipelineRunVariable
from .run_parameter import RunParameter
from .run_parameter_type import RunParameterType
from .run_state import RunState

__all__ = [
"PipelineRunState",
"RunParameter",
"RunParameterType",
"RunState",
"PipelineRunVariable",
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
)
from data_factory_testing_framework.exceptions.variable_does_not_exist_error import VariableDoesNotExistError
from data_factory_testing_framework.generated.models import DependencyCondition, VariableSpecification
from data_factory_testing_framework.models.base.pipeline_run_variable import PipelineRunVariable
from data_factory_testing_framework.models.base.run_parameter import RunParameter
from data_factory_testing_framework.models.state.run_state import RunState
from data_factory_testing_framework.state.pipeline_run_variable import PipelineRunVariable
from data_factory_testing_framework.state.run_parameter import RunParameter
from data_factory_testing_framework.state.run_state import RunState


class PipelineRunState(RunState):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Generic, TypeVar

from data_factory_testing_framework.models.base.run_parameter_type import RunParameterType
from data_factory_testing_framework.state.run_parameter_type import RunParameterType

T = TypeVar("T")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

from data_factory_testing_framework.models.base.run_parameter import RunParameter
from data_factory_testing_framework.state.run_parameter import RunParameter


class RunState:
Expand Down
Loading

0 comments on commit f7b807a

Please sign in to comment.