Example #1
0
    def test_relation(self):
        from mixer.backend.mongoengine import Mixer
        mixer = Mixer(commit=False)

        post = mixer.blend(
            'tests.test_mongoengine.Post', author__username='******')
        self.assertEqual(post.author.username, 'foo')

        bookmark = mixer.blend(Bookmark)
        self.assertTrue(bookmark.bookmark)
Example #2
0
def test_relation():
    from mixer.backend.mongoengine import Mixer

    mixer = Mixer(commit=False)

    post = mixer.blend(
        'tests.test_mongoengine.Post', author__username='******')
    assert post.author.username == 'foo'

    bookmark = mixer.blend(Bookmark)
    assert not bookmark.bookmark

    bookmark = mixer.blend(Bookmark, bookmark=mixer.RANDOM)
    assert bookmark.bookmark
Example #3
0
    def test_base(self):
        from mixer.backend.mongoengine import Mixer
        mixer = Mixer(commit=False)

        self.assertTrue(mixer)

        user = mixer.blend(User)
        self.assertTrue(user.id)
Example #4
0
def test_decimal_field_max_value():
    from mixer.backend.mongoengine import Mixer

    class NewPost(Post):
        rating = DecimalField(required=True, max_value=0)

    mixer = Mixer(commit=False)

    post = mixer.blend(NewPost)
    assert post.rating < 0
Example #5
0
def test_embedded_document_list_field():
    from mixer.backend.mongoengine import Mixer

    class NewPost(Post):
        comments = EmbeddedDocumentListField(Comment, required=True)

    mixer = Mixer(commit=False)

    post = mixer.blend(NewPost)
    assert post.validate() is None
    assert len(post.comments) > 0
Example #6
0
def test_base():
    from mixer.backend.mongoengine import Mixer

    mixer = Mixer(commit=False)
    assert mixer

    now = datetime.datetime.now()

    user = mixer.blend(User)
    assert user.id
    assert user.email
    assert user.created_at
    assert user.created_at >= now