Beispiel #1
0
    def test_init(self):
        """Test successful DateTime Field initialization"""

        created_at = DateTime()
        assert created_at is not None

        value = datetime.now()
        assert value == created_at._load(value)
Beispiel #2
0
class Recalled(BaseEvent):
    email = String()
    sent_at = DateTime()

    class Meta:
        aggregate_cls = Email
        stream_name = "recalls"
Beispiel #3
0
class CommentViaWithReference(BaseEntity):
    content = Text()
    added_on = DateTime()
    posting = Reference("tests.aggregate.elements.PostVia")

    class Meta:
        aggregate_cls = PostViaWithReference
Beispiel #4
0
class CommentVia(BaseEntity):
    content = Text()
    added_on = DateTime()
    posting_id = String()

    class Meta:
        aggregate_cls = PostVia
Beispiel #5
0
class Post(BaseAggregate):
    title = String(required=True, max_length=1000)
    slug = String(required=True, max_length=1024)
    content = Text(required=True)
    posted_at = DateTime(required=True, default=datetime.now())

    post_meta = HasOne("tests.repository.child_entities.PostMeta")
    comments = HasMany("tests.repository.child_entities.Comment")
Beispiel #6
0
            class Comment(BaseEntity):
                content = Text()
                added_on = DateTime()

                post = Reference("Post")

                class Meta:
                    aggregate_cls = Post
class Post(BaseAggregate):
    title = String(required=True, max_length=1000)
    slug = String(required=True, max_length=1024)
    content = Text(required=True)
    posted_at = DateTime(required=True, default=datetime.now())

    meta = HasOne("tests.unit_of_work.aggregate_elements.PostMeta")
    comments = HasMany("tests.unit_of_work.aggregate_elements.Comment")
class Comment(BaseEntity):
    content = Text(required=True)
    commented_at = DateTime(required=True, default=datetime.now())

    post = Reference(Post)

    class Meta:
        aggregate_cls = Post
Beispiel #9
0
    def test_type_casting(self):
        """Test type casting and validation for the Field"""

        created_at = DateTime()
        today = datetime.now()
        # Test date being passed as value
        assert created_at._load(today.date()) == datetime(
            today.year, today.month, today.day)

        # Test string dates being passed as value
        assert created_at._load("2018-03-16") == datetime(2018, 3, 16)
        assert created_at._load("2018-03-16 10:23:32") == datetime(
            2018, 3, 16, 10, 23, 32)

        # Test for invalid datetime
        with pytest.raises(ValidationError):
            assert created_at._load("2018-03-16 10 23 32")
class Sent(BaseEvent):
    email = String()
    sent_at = DateTime()
class Activated(BaseEvent):
    id = Identifier()
    activated_at = DateTime()
class Email(BaseEventSourcedAggregate):
    email = String()
    sent_at = DateTime()
Beispiel #13
0
 class Post(BaseAggregate):
     title = String(required=True, max_length=1000)
     slug = String(required=True, max_length=1024)
     content = Text(required=True)
     posted_at = DateTime(required=True, default=datetime.utcnow)
class Login(BaseCommand):
    id = Identifier()
    activated_at = DateTime()

    class Meta:
        aggregate_cls = User
Beispiel #15
0
class LoggedIn(BaseEvent):
    id = Identifier()
    activated_at = DateTime()

    class Meta:
        aggregate_cls = User
Beispiel #16
0
        class TimeStamped:
            created_at = DateTime(default=datetime.utcnow)
            updated_at = DateTime(default=datetime.utcnow)

            class Meta:
                abstract = True
Beispiel #17
0
    def test_null_values(self):
        created_at = DateTime()

        assert created_at._load(None) is None
        assert created_at._load("") is None
Beispiel #18
0
class Person(BaseAggregate):
    first_name = String(max_length=50, required=True)
    last_name = String(max_length=50, required=True)
    age = Integer(default=21)
    created_at = DateTime(default=datetime.now())
Beispiel #19
0
class Role(BaseAggregate):
    name = String(max_length=15, required=True)
    created_on = DateTime(default=datetime.today())
Beispiel #20
0
class Event(BaseAggregate):
    name = String(max_length=255)
    created_at = DateTime(default=datetime.utcnow())
    payload = Dict()
class Send(BaseCommand):
    email = String()
    sent_at = DateTime()
class Published(BaseEvent):
    id = Identifier(required=True)
    published_time = DateTime(default=datetime.utcnow)

    class Meta:
        aggregate_cls = Post
class Published(BaseEvent):
    id = Identifier(required=True)
    published_time = DateTime(default=datetime.utcnow)
class Activate(BaseCommand):
    id = Identifier()
    activated_at = DateTime()