Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #657 from Clariteia/0.3.0
Browse files Browse the repository at this point in the history
0.3.0
  • Loading branch information
Sergio García Prado authored Nov 15, 2021
2 parents 6a0aa0e + 819ba83 commit 35b1c69
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 515 deletions.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,11 @@ History
--------------------

* Fix bug related with dependency injections over `minos.*` modules.

0.3.0 (2021-11-15)
--------------------

* Add `services` and `middleware` sections to `MinosConfig`.
* Remove `Command`, `CommandReply`, `CommandStatus` and `Event` (moved to `minos.networks`).
* Remove `MinosBroker` and `MinosHandler` (moved to `minos.networks`).
* Remove `MinosSagaManager` (moved to `minos.saga`).
16 changes: 3 additions & 13 deletions minos/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__version__ = "0.2.1"
__author__ = """Clariteia Devs"""
__email__ = "devs@clariteia.com"
__version__ = "0.3.0"

from .configuration import (
BROKER,
COMMANDS,
DISCOVERY,
QUEUE,
REPOSITORY,
Expand Down Expand Up @@ -72,13 +73,9 @@
AvroSchemaDecoder,
AvroSchemaEncoder,
BucketModel,
Command,
CommandReply,
CommandStatus,
DataTransferObject,
DeclarativeModel,
DynamicModel,
Event,
Field,
GenericTypeProjector,
MinosModel,
Expand All @@ -91,10 +88,6 @@
TypeHintComparator,
is_model_type,
)
from .networks import (
MinosBroker,
MinosHandler,
)
from .pools import (
MinosPool,
)
Expand All @@ -105,9 +98,6 @@
MinosBinaryProtocol,
MinosJsonBinaryProtocol,
)
from .saga import (
MinosSagaManager,
)
from .setup import (
MinosSetup,
)
Expand Down
1 change: 0 additions & 1 deletion minos/common/configuration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .config import (
BROKER,
COMMANDS,
DISCOVERY,
QUEUE,
REPOSITORY,
Expand Down
23 changes: 13 additions & 10 deletions minos/common/configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
SERVICE = namedtuple("Service", "name aggregate injections services")
STORAGE = namedtuple("Storage", "path")

COMMANDS = namedtuple("Commands", "service")
QUERIES = namedtuple("Queries", "service")
SAGA = namedtuple("Saga", "storage")
REST = namedtuple("Rest", "host port")
REPOSITORY = namedtuple("Repository", "database user password host port")
Expand Down Expand Up @@ -220,21 +218,26 @@ def _broker_queue(self) -> QUEUE:
)

@property
def commands(self) -> COMMANDS:
def services(self) -> list[str]:
"""Get the commands config.
:return: A ``COMMAND`` NamedTuple instance.
:return: A list containing the service class names as string values..
"""
service = self._get("commands.service")
return COMMANDS(service=service)
try:
return self._get("services")
except MinosConfigException:
return list()

@property
def queries(self) -> QUERIES:
"""Get the queries config.
def middleware(self) -> list[str]:
"""Get the commands config.
:return: A ``QUERIES`` NamedTuple instance.
:return: A list containing the service class names as string values..
"""
return QUERIES(service=self._get("queries.service"))
try:
return self._get("middleware")
except MinosConfigException:
return list()

@property
def saga(self) -> SAGA:
Expand Down
4 changes: 0 additions & 4 deletions minos/common/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
Model,
)
from .declarative import (
Command,
CommandReply,
CommandStatus,
DeclarativeModel,
Event,
MinosModel,
)
from .dynamic import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
get_type_hints,
)

from ...meta import (
from ..meta import (
self_or_classmethod,
)
from ..abc import (
from .abc import (
Model,
)
from ..types import (
from .types import (
MissingSentinel,
ModelType,
TypeHintComparator,
Expand Down
10 changes: 0 additions & 10 deletions minos/common/model/declarative/__init__.py

This file was deleted.

52 changes: 0 additions & 52 deletions minos/common/model/declarative/networks.py

This file was deleted.

53 changes: 0 additions & 53 deletions minos/common/networks.py

This file was deleted.

49 changes: 0 additions & 49 deletions minos/common/saga.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "minos_microservice_common"
version = "0.2.1"
version = "0.3.0"
description = "Python Package with common Classes and Utilities used in Minos Microservices."
readme = "README.md"
repository = "https://github.com/clariteia/minos_microservice_common"
Expand Down
21 changes: 15 additions & 6 deletions tests/test_common/test_configuration/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import unittest
from unittest.mock import (
patch,
)

from minos.common import (
MinosConfig,
Expand Down Expand Up @@ -47,13 +50,19 @@ def test_config_events_queue_database(self):
self.assertEqual(10, queue.records)
self.assertEqual(2, queue.retry)

def test_config_commands_service(self):
commands = self.config.commands
self.assertEqual("minos.services.OrderService", commands.service)
def test_services(self):
self.assertEqual(["tests.services.OrderService", "tests.services.OrderQueryService"], self.config.services)

def test_services_not_defined(self):
with patch("minos.common.MinosConfig._get", side_effect=MinosConfigException("")):
self.assertEqual([], self.config.services)

def test_middleware(self):
self.assertEqual(["tests.middleware.performance_tracking"], self.config.middleware)

def test_config_queries_service(self):
query = self.config.queries
self.assertEqual("minos.services.OrderQueryService", query.service)
def test_middleware_not_defined(self):
with patch("minos.common.MinosConfig._get", side_effect=MinosConfigException("")):
self.assertEqual([], self.config.middleware)

def test_config_saga_storage(self):
config = MinosConfig(path=self.config_file_path, with_environment=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)


class MyTestCase(unittest.TestCase):
class TestMinosConfigParameterized(unittest.TestCase):
def setUp(self) -> None:
self.config_file_path = BASE_PATH / "test_config.yml"

Expand All @@ -27,16 +27,6 @@ def test_overwrite_with_parameter_priority(self):
repository = config.repository
self.assertEqual("bar", repository.database)

def test_queries_service(self):
config = MinosConfig(path=self.config_file_path, queries_service="test")
query = config.queries
self.assertEqual("test", query.service)

def test_commands_service(self):
config = MinosConfig(path=self.config_file_path, commands_service="test")
commands = config.commands
self.assertEqual("test", commands.service)

def test_config_discovery(self):
config = MinosConfig(
path=self.config_file_path,
Expand Down
12 changes: 0 additions & 12 deletions tests/test_common/test_configuration/test_config_with_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ def test_overwrite_with_environment_false(self):
repository = self.config.repository
self.assertEqual("order_db", repository.database)

@mock.patch.dict(os.environ, {"MINOS_QUERIES_SERVICE": "src.Test"})
def test_config_queries_service(self):
query = self.config.queries

self.assertEqual("src.Test", query.service)

@mock.patch.dict(os.environ, {"MINOS_COMMANDS_SERVICE": "src.Test"})
def test_config_commands_service(self):
commands = self.config.commands

self.assertEqual("src.Test", commands.service)

@mock.patch.dict(os.environ, {"MINOS_DISCOVERY_CLIENT": "some-type"})
@mock.patch.dict(os.environ, {"MINOS_DISCOVERY_HOST": "some-host"})
@mock.patch.dict(os.environ, {"MINOS_DISCOVERY_PORT": "333"})
Expand Down
Loading

0 comments on commit 35b1c69

Please sign in to comment.