summaryrefslogtreecommitdiff
path: root/examples/flask_alchemy/demoapp_factories.py
diff options
context:
space:
mode:
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)