Permalink
Browse files

more tests to recipe

  • Loading branch information...
1 parent 0e06a47 commit 1ac6c8ff91fd9a20b2b9d8963dd486cc02735ccc @vandersonmota committed Oct 16, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 test/generic/tests/test_recipes.py
@@ -1,5 +1,7 @@
#coding: utf-8
+from random import choice
+from mock import patch
from decimal import Decimal
from django.test import TestCase
from model_mommy import mommy
@@ -62,6 +64,16 @@ def test_accepts_callable(self):
value = r.make().blank_char_field
self.assertEqual(value, 'callable!!')
+ def test_always_calls_when_creating(self):
+ with patch('test.generic.tests.test_recipes.choice') as choice_mock:
+ l = ['foo', 'bar', 'spam', 'eggs']
+ r = Recipe(DummyBlankFieldsModel,
+ blank_char_field = lambda: choice(l)
+ )
+ r.make().blank_char_field
+ r.make().blank_char_field
+ self.assertEqual(choice_mock.call_count, 2)
+
def test_make_recipes_with_args(self):
"""
Overriding some fields values at recipe execution

0 comments on commit 1ac6c8f

Please sign in to comment.