From ac64870759ce607ffb5c1306e3ea915654f1b09f Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Mon, 2 Sep 2024 17:53:38 +0200 Subject: [PATCH] 64: Add some unit test for configuration and raise coverage. --- pyproject.toml | 9 +-------- src/omotes_sdk/workflow_type.py | 16 ++++++++-------- unit_test/internal/common/__init__.py | 0 unit_test/internal/common/test_config.py | 9 +++++++++ unit_test/internal/worker/test_configs.py | 9 +++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 unit_test/internal/common/__init__.py create mode 100644 unit_test/internal/common/test_config.py create mode 100644 unit_test/internal/worker/test_configs.py diff --git a/pyproject.toml b/pyproject.toml index 97fd5b4..4b49224 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,18 +70,11 @@ requires = [ enabled = true [tool.pytest.ini_options] -addopts = "--cov=omotes_sdk --cov-report html --cov-report term-missing --cov-fail-under 57.5" +addopts = "--cov=omotes_sdk --cov-report html --cov-report term-missing --cov-fail-under 64" [tool.coverage.run] source = ["src"] -[tool.coverage.report] -# Regexes for lines to exclude from consideration -exclude_also = [ - # Don't complain about missing code: - "\\.\\.\\.", -] - [tool.flake8] exclude = [ '.venv/*', diff --git a/src/omotes_sdk/workflow_type.py b/src/omotes_sdk/workflow_type.py index 19f6ef3..fec80f8 100644 --- a/src/omotes_sdk/workflow_type.py +++ b/src/omotes_sdk/workflow_type.py @@ -27,13 +27,13 @@ class WrongFieldTypeException(Exception): """Thrown when param_dict contains a value of the wrong type for some parameter.""" - ... + ... # pragma: no cover class MissingFieldException(Exception): """Thrown when param_dict does not contain the value for some parameter.""" - ... + ... # pragma: no cover @dataclass(eq=True, frozen=True) @@ -66,7 +66,7 @@ def get_pb_protocol_equivalent() -> Type[ conversions. It is used to convert the workflow parameter from the Python description to the protobuf definition in AvailableWorkflows. """ - ... + ... # pragma: no cover @abstractmethod def to_pb_message(self) -> Union[ @@ -80,7 +80,7 @@ def to_pb_message(self) -> Union[ :return: Protobuf message representation. """ - ... + ... # pragma: no cover @classmethod @abstractmethod @@ -95,7 +95,7 @@ def from_pb_message( :param parameter_type_pb: protobuf message containing the parameter type parameters. :return: class instance. """ - ... + ... # pragma: no cover @classmethod @abstractmethod @@ -105,7 +105,7 @@ def from_json_config(cls, json_config: Dict) -> Self: :param json_config: dictionary with configuration. :return: class instance. """ - ... + ... # pragma: no cover @staticmethod @abstractmethod @@ -115,7 +115,7 @@ def from_pb_value(value: PBStructCompatibleTypes) -> ParamsDictValues: Protobuf structs do not support int, datetime or timestamps natively. This function is used to unpack the value from a protobuf-compatible datatype. """ - ... + ... # pragma: no cover @staticmethod @abstractmethod @@ -125,7 +125,7 @@ def to_pb_value(value: ParamsDictValues) -> PBStructCompatibleTypes: Protobuf structs do not support int, datetime or timestamps natively. This function is used to unpack the value to a protobuf-compatible datatype. """ - ... + ... # pragma: no cover @dataclass(eq=True, frozen=True) diff --git a/unit_test/internal/common/__init__.py b/unit_test/internal/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/unit_test/internal/common/test_config.py b/unit_test/internal/common/test_config.py new file mode 100644 index 0000000..ce02b8a --- /dev/null +++ b/unit_test/internal/common/test_config.py @@ -0,0 +1,9 @@ +import unittest + +from omotes_sdk.internal.common.config import EnvRabbitMQConfig + + +class TestEnvRabbitMQConfig(unittest.TestCase): + def test__init__no_errors(self) -> None: + # Act / Assert + EnvRabbitMQConfig() diff --git a/unit_test/internal/worker/test_configs.py b/unit_test/internal/worker/test_configs.py new file mode 100644 index 0000000..7c99d32 --- /dev/null +++ b/unit_test/internal/worker/test_configs.py @@ -0,0 +1,9 @@ +import unittest + +from omotes_sdk.internal.worker.configs import WorkerConfig + + +class TestWorkerConfigConfig(unittest.TestCase): + def test__init__no_errors(self) -> None: + # Act / Assert + WorkerConfig()