From f33877d2206a3ebcc5ec4909fb234e7ac70ce0cf Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Thu, 25 Jul 2024 15:13:52 -0700 Subject: [PATCH] Misc fixes and improve coverage --- src/protean/__init__.py | 2 ++ src/protean/exceptions.py | 17 ----------------- tests/reflection/test_fields.py | 10 +++++----- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/protean/__init__.py b/src/protean/__init__.py index d48332dd..081575ac 100644 --- a/src/protean/__init__.py +++ b/src/protean/__init__.py @@ -2,6 +2,7 @@ from .core.aggregate import apply, atomic_change from .core.entity import invariant +from .core.event import BaseEvent from .core.model import BaseModel from .core.queryset import Q, QuerySet from .core.unit_of_work import UnitOfWork @@ -12,6 +13,7 @@ from .utils.mixins import handle __all__ = [ + "BaseEvent", "BaseModel", "Domain", "Engine", diff --git a/src/protean/exceptions.py b/src/protean/exceptions.py index 524b350f..3e887ad7 100644 --- a/src/protean/exceptions.py +++ b/src/protean/exceptions.py @@ -79,23 +79,6 @@ class ValidationError(ProteanException): """ -class UsecaseExecutionError(Exception): - """Raised when a failure response is encountered on executing a usecase - - :param value: a tuple comprising of the error code and error message - :type value: tuple - :param orig_exc: Optional original exception raised in the usecase - :param orig_trace: Optional trace of the original exception in the usecase - """ - - def __init__(self, value, orig_exc=None, orig_trace=None, **kwargs): - self.value = value - self.orig_exc = orig_exc - self.orig_trace = orig_trace - - super().__init__(**kwargs) - - class SendError(Exception): """Raised on email dispatch failure.""" diff --git a/tests/reflection/test_fields.py b/tests/reflection/test_fields.py index 29db6ff2..ae95e347 100644 --- a/tests/reflection/test_fields.py +++ b/tests/reflection/test_fields.py @@ -3,7 +3,7 @@ from protean.core.aggregate import BaseAggregate from protean.exceptions import IncorrectUsageError from protean.fields import Integer, String -from protean.utils.reflection import declared_fields +from protean.utils.reflection import fields class Person(BaseAggregate): @@ -11,9 +11,9 @@ class Person(BaseAggregate): age = Integer() -def test_declared_fields(): - assert len(declared_fields(Person)) == 3 - assert all(key in declared_fields(Person) for key in ["name", "age", "id"]) +def test_fields(): + assert len(fields(Person)) == 4 + assert all(key in fields(Person) for key in ["_version", "name", "age", "id"]) def test_fields_on_non_element(): @@ -21,7 +21,7 @@ class Dummy: pass with pytest.raises(IncorrectUsageError) as exception: - declared_fields(Dummy) + fields(Dummy) assert exception.value.messages == { "field": [