Example #1
0
    def create(self, article_dto: CreateArticleDTO):
        article = Article(title=article_dto.title,
                          slug=slugify(article_dto.title),
                          description=article_dto.description,
                          body=article_dto.body,
                          tag_list=article_dto.tag_list,
                          author=article_dto.author)

        current_domain.publish(TagsAdded(tag_list=article_dto.tag_list))

        return article
Example #2
0
    def add_newcomer(cls, person_dict):
        """Factory method to add a new Person to the system"""
        newcomer = Person(
            first_name=person_dict['first_name'],
            last_name=person_dict['last_name'],
            age=person_dict['age'],
            )

        # Publish Event via the domain
        current_domain.publish(PersonAdded(person=newcomer))

        return newcomer
Example #3
0
    def add_newcomer(cls, person_dict):
        """Factory method to add a new Person to the system"""
        newcomer = Person(
            first_name=person_dict["first_name"],
            last_name=person_dict["last_name"],
            age=person_dict["age"],
        )

        # Publish Event via the domain
        current_domain.publish(PersonAdded(**newcomer.to_dict()))

        return newcomer
Example #4
0
def test_inline_event_processing_on_publish_in_sync_mode(test_domain):
    test_domain.register(Registered)
    test_domain.register(UserEventHandler, stream_name="user")

    current_domain.publish(
        Registered(
            user_id=str(uuid4()),
            email="*****@*****.**",
            name="John Doe",
            password_hash="hash",
        )
    )

    global counter
    assert counter == 1