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)
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
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)
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
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
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