# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
#     """
#     `EventSourcedEntity` with saner mutator routing & naming:
# 
#     >>> class Asset(BaseAggregate):
#     >>>    class Created(BaseAggregate.Created):
#     >>>        def mutate(event, klass):
#     >>>            return klass(...)
#     >>>
#     >>>    class Updated(DomainEvent):
#     >>>        def mutate(event, instance):
#     >>>            instance.connect = True
#     >>>            return instance
#     """
# 
#     @classmethod
#     def is_abstract_class(cls):
#         return is_abstract(cls)
# 
#     @classmethod
#     def mutate(cls, aggregate=None, event=None):
#         if aggregate:
#             aggregate._validate_originator(event)
# 
#         if not hasattr(event, 'mutate_event'):
#             msg = "{} does not provide a mutate_event() method.".format(event.__class__)
#             raise NotImplementedError(msg)
# 
#         aggregate = event.mutate_event(event, aggregate or cls)
#         aggregate._increment_version()
#         return aggregate
# 
#     @classmethod
#     def create_for_event(cls, event):
#         aggregate = cls(
#             entity_id=event.entity_id,
#             domain_event_id=event.domain_event_id,
#             entity_version=event.entity_version,
#         )
#         return aggregate
# 
# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
# class BaseEntity(BaseAggregate):
#     def is_abstract_class(cls):
#     def mutate(cls, aggregate=None, event=None):
#     def create_for_event(cls, event):
#     def is_abstract_class(cls):
#     def mutate(cls, entity=None, event=None):
# 
# Path: djangoevents/utils_abstract.py
# def abstract(cls):
#     """
#     Decorator marking classes as abstract.
# 
#     The "abstract" mark is an internal tag.  Classes can be checked for
#     being abstract with the `is_abstract` function.  The tag is non
#     inheritable: every class or subclass has to be explicitly marked
#     with the decorator to be considered abstract.
#     """
# 
#     _abstract_classes.add(cls)
#     return cls
# 
# Path: djangoevents/utils_abstract.py
# def is_abstract(cls):
#     return cls in _abstract_classes


from djangoevents.domain import BaseAggregate
from djangoevents.domain import DomainEvent
from djangoevents.utils_abstract import abstract
from djangoevents.utils_abstract import is_abstract


def test_subclass_of_abstract_event_is_not_abstract():

    class Aggregate(BaseAggregate):

        @abstract
        class Event1(DomainEvent):
            pass

        class Event2(Event1):
            pass

    assert is_abstract(Aggregate.Event1)

# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
#     """
#     `EventSourcedEntity` with saner mutator routing & naming:
# 
#     >>> class Asset(BaseAggregate):
#     >>>    class Created(BaseAggregate.Created):
#     >>>        def mutate(event, klass):
#     >>>            return klass(...)
#     >>>
#     >>>    class Updated(DomainEvent):
#     >>>        def mutate(event, instance):
#     >>>            instance.connect = True
#     >>>            return instance
#     """
# 
#     @classmethod
#     def is_abstract_class(cls):
#         return is_abstract(cls)
# 
#     @classmethod
#     def mutate(cls, aggregate=None, event=None):
#         if aggregate:
#             aggregate._validate_originator(event)
# 
#         if not hasattr(event, 'mutate_event'):
#             msg = "{} does not provide a mutate_event() method.".format(event.__class__)
#             raise NotImplementedError(msg)
# 
#         aggregate = event.mutate_event(event, aggregate or cls)
#         aggregate._increment_version()
#         return aggregate
# 
#     @classmethod
#     def create_for_event(cls, event):
#         aggregate = cls(
#             entity_id=event.entity_id,
#             domain_event_id=event.domain_event_id,
#             entity_version=event.entity_version,
#         )
#         return aggregate
# 
# Path: djangoevents/domain.py
# class BaseAggregate(EventSourcedEntity):
# class BaseEntity(BaseAggregate):
#     def is_abstract_class(cls):
#     def mutate(cls, aggregate=None, event=None):
#     def create_for_event(cls, event):
#     def is_abstract_class(cls):
#     def mutate(cls, entity=None, event=None):
# 
# Path: djangoevents/utils_abstract.py
# def abstract(cls):
#     """
#     Decorator marking classes as abstract.
# 
#     The "abstract" mark is an internal tag.  Classes can be checked for
#     being abstract with the `is_abstract` function.  The tag is non
#     inheritable: every class or subclass has to be explicitly marked
#     with the decorator to be considered abstract.
#     """
# 
#     _abstract_classes.add(cls)
#     return cls
# 
# Path: djangoevents/utils_abstract.py
# def is_abstract(cls):
#     return cls in _abstract_classes


# Path: djangoevents/tests/test_utils_abstract.py
from djangoevents.domain import BaseAggregate
from djangoevents.domain import DomainEvent
from djangoevents.utils_abstract import abstract
from djangoevents.utils_abstract import is_abstract



def test_subclass_of_abstract_event_is_not_abstract():

    class Aggregate(BaseAggregate):

        @abstract
        class Event1(DomainEvent):
            pass

        class Event2(Event1):
            pass

    assert is_abstract(Aggregate.Event1)

    assert not is_abstract(Aggregate.Event2)