summaryrefslogtreecommitdiff
path: root/examples/flask_alchemy/demoapp_factories.py
blob: f32f8c39fd18858952f3c8be0bbbd539423a60e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import factory
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)