Example #1
0
def test_required_references_throw_a_validation_error_on_empty():
    ref = Reference(Address, required=True)

    with pytest.raises(ValidationError) as exc:
        ref._load(None)

    assert exc.value.messages == {"unlinked": ["is required"]}
Example #2
0
            class Comment(BaseEntity):
                content = Text()
                added_on = DateTime()

                post = Reference("Post")
                foo = Reference("Foo")

                class Meta:
                    aggregate_cls = Post
Example #3
0
        class Comment(BaseEntity):
            content = Text(required=True)

            post = Reference("Post")

            class Meta:
                aggregate_cls = "Post"
Example #4
0
            class Author(BaseEntity):
                first_name = String(required=True, max_length=25)
                last_name = String(max_length=25)
                account = Reference("Account")

                class Meta:
                    aggregate_cls = Account
Example #5
0
class CommentViaWithReference(BaseEntity):
    content = Text()
    added_on = DateTime()
    posting = Reference("tests.aggregate.elements.PostVia")

    class Meta:
        aggregate_cls = PostViaWithReference
Example #6
0
class PostMeta(BaseEntity):
    likes = Integer(default=0)

    post = Reference(Post)

    class Meta:
        aggregate_cls = Post
Example #7
0
class Author(BaseEntity):
    first_name = String(required=True, max_length=25)
    last_name = String(max_length=25)
    posts = HasMany("tests.aggregate.elements.Post")
    account = Reference("tests.aggregate.elements.Account")

    class Meta:
        aggregate_cls = Account
Example #8
0
class Comment(BaseEntity):
    content = Text(required=True)
    commented_at = DateTime(required=True, default=datetime.now())

    post = Reference(Post)

    class Meta:
        aggregate_cls = Post
Example #9
0
        class Comment:
            content = String(max_length=500)
            post = Reference("Post")

            class Meta:
                aggregate_cls = Post
Example #10
0
class User(BaseAggregate):
    address = Reference(Address, required=True)
Example #11
0
class PostViaWithReference(BaseAggregate):
    content = Text(required=True)
    comments = HasMany(
        "tests.aggregate.elements.CommentViaWithReference", via="posting_id"
    )
    author = Reference("tests.aggregate.elements.Author")
Example #12
0
 class User(BaseView):
     user_id = Identifier(identifier=True)
     role = Reference(Role)
Example #13
0
class ProfileViaWithReference(BaseAggregate):
    about_me = Text()
    ac = Reference("tests.aggregate.elements.AccountViaWithReference")
Example #14
0
class ProfileWithAccountId(BaseAggregate):
    about_me = Text()
    account = Reference("tests.aggregate.elements.AccountWithId")
Example #15
0
class Profile(BaseAggregate):
    about_me = Text()
    account = Reference("tests.aggregate.elements.Account", via="username")
Example #16
0
class PostMeta(BaseEntity):
    likes = Integer(default=0)

    post = Reference(Post)
Example #17
0
class Post(BaseAggregate):
    content = Text(required=True)
    comments = HasMany("tests.aggregate.elements.Comment")
    author = Reference("tests.aggregate.elements.Author")