summaryrefslogtreecommitdiff
path: root/examples/flask_alchemy/demoapp_factories.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2015-07-15 23:15:13 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2015-07-15 23:15:13 +0200
commitb0fbd24c69a155c4f9d58f5e4dab8209afeb3660 (patch)
tree7135e74933e7166563296023527aebf1122d4ea8 /examples/flask_alchemy/demoapp_factories.py
parent63edb526bc4efd8cf7abe260f2787f55d2953e39 (diff)
downloadfactory-boy-b0fbd24c69a155c4f9d58f5e4dab8209afeb3660.tar
factory-boy-b0fbd24c69a155c4f9d58f5e4dab8209afeb3660.tar.gz
Add examples folder.
This should contain examples of "using factory_boy with third-party frameworks".
Diffstat (limited to 'examples/flask_alchemy/demoapp_factories.py')
-rw-r--r--examples/flask_alchemy/demoapp_factories.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/flask_alchemy/demoapp_factories.py b/examples/flask_alchemy/demoapp_factories.py
new file mode 100644
index 0000000..6b71d04
--- /dev/null
+++ b/examples/flask_alchemy/demoapp_factories.py
@@ -0,0 +1,27 @@
+import factory
+import factory.alchemy
+import factory.fuzzy
+
+import demoapp
+
+
+class BaseFactory(factory.alchemy.SQLAlchemyModelFactory):
+ class Meta:
+ abstract = True
+ sqlalchemy_session = demoapp.db.session
+
+
+class UserFactory(BaseFactory):
+ class Meta:
+ model = demoapp.User
+
+ username = factory.fuzzy.FuzzyText()
+ email = factory.fuzzy.FuzzyText()
+
+
+class UserLogFactory(BaseFactory):
+ class Meta:
+ model = demoapp.UserLog
+
+ message = factory.fuzzy.FuzzyText()
+ user = factory.SubFactory(UserFactory)