aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_faker.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_faker.py b/tests/test_faker.py
index 41f8e19..99e54af 100644
--- a/tests/test_faker.py
+++ b/tests/test_faker.py
@@ -21,9 +21,12 @@
# THE SOFTWARE.
-import factory
import unittest
+import faker.providers
+
+import factory
+
class MockFaker(object):
def __init__(self, expected):
@@ -103,3 +106,30 @@ class FakerTests(unittest.TestCase):
self.assertEqual("John", profile.first_name)
self.assertEqual("Valjean", profile.last_name)
+ def test_add_provider(self):
+ class Face(object):
+ def __init__(self, smiley, french_smiley):
+ self.smiley = smiley
+ self.french_smiley = french_smiley
+
+ class FaceFactory(factory.Factory):
+ class Meta:
+ model = Face
+
+ smiley = factory.Faker('smiley')
+ french_smiley = factory.Faker('smiley', locale='fr_FR')
+
+ class SmileyProvider(faker.providers.BaseProvider):
+ def smiley(self):
+ return ':)'
+
+ class FrenchSmileyProvider(faker.providers.BaseProvider):
+ def smiley(self):
+ return '(:'
+
+ factory.Faker.add_provider(SmileyProvider)
+ factory.Faker.add_provider(FrenchSmileyProvider, 'fr_FR')
+
+ face = FaceFactory()
+ self.assertEqual(":)", face.smiley)
+ self.assertEqual("(:", face.french_smiley)