示例#1
0
    def append(self, domain_event):
        assert isinstance(domain_event, DomainEvent)

        # Serialize the domain event.
        stored_event = serialize_domain_event(domain_event)

        # Append the stored event to the stored event repo.
        self.stored_event_repo.append(stored_event)
示例#2
0
 def test_serialize_domain_event(self):
     datetime_now = datetime.datetime(2015, 9, 8, 16, 20, 50, 577429)
     datetime_now_tzaware = datetime.datetime(2015, 9, 8, 16, 20, 50, 577429, tzinfo=utc_timezone)
     date_now = datetime.date(2015, 9, 8)
     event1 = DomainEvent(a=1, b=2, c=datetime_now, d=datetime_now_tzaware, e=date_now, entity_version=0, entity_id='entity1', timestamp=3)
     stored_event = serialize_domain_event(event1)
     self.assertEqual('DomainEvent::entity1', stored_event.stored_entity_id)
     self.assertEqual('eventsourcing.domain.model.events#DomainEvent', stored_event.event_topic)
     self.assertEqual('{"a":1,"b":2,"c":{"ISO8601_datetime":"2015-09-08T16:20:50.577429"},"d":{"ISO8601_datetime":"2015-09-08T16:20:50.577429+0000"},"e":{"ISO8601_date":"2015-09-08"},"entity_id":"entity1","entity_version":0,"timestamp":3}',
                      stored_event.event_attrs)