Esempio n. 1
0
def write_comment(post=None):
    if not post:
        post = Post.objects.order_by('?')[0]

    mixer.blend(
        Comment, post=post, user=mixer.select(is_active=True))

    return post
Esempio n. 2
0
    def test_select(self):
        from mixer.backend.django import mixer

        mixer.cycle(3).blend(Rabbit)
        hole = mixer.blend(Hole, rabbit=mixer.select)
        self.assertFalse(hole.rabbit)

        rabbits = Rabbit.objects.all()
        hole = mixer.blend(Hole, owner=mixer.select)
        self.assertTrue(hole.owner in rabbits)

        rabbit = rabbits[0]
        hole = mixer.blend(Hole, owner=mixer.select(email=rabbit.email))
        self.assertEqual(hole.owner, rabbit)
Esempio n. 3
0
    def test_select(self):
        from mixer.backend.django import mixer

        mixer.cycle(3).blend(Rabbit)
        hole = mixer.blend(Hole, rabbit=mixer.select)
        self.assertFalse(hole.rabbit)

        rabbits = Rabbit.objects.all()
        hole = mixer.blend(Hole, owner=mixer.select)
        self.assertTrue(hole.owner in rabbits)

        rabbit = rabbits[0]
        hole = mixer.blend(Hole, owner=mixer.select(email=rabbit.email))
        self.assertEqual(hole.owner, rabbit)
Esempio n. 4
0
def write_post():
    post = mixer.blend(Post, user=mixer.select(is_active=True))
    return post