From e589ec1d92788f3cbd82e3007ca797e0833b3b50 Mon Sep 17 00:00:00 2001 From: sloria Date: Sun, 27 Jul 2014 19:41:00 -0400 Subject: [PATCH] Add abstract base factory --- {{cookiecutter.app_name}}/tests/factories.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.app_name}}/tests/factories.py b/{{cookiecutter.app_name}}/tests/factories.py index 4babc26..db06fd4 100644 --- a/{{cookiecutter.app_name}}/tests/factories.py +++ b/{{cookiecutter.app_name}}/tests/factories.py @@ -5,13 +5,19 @@ from factory.alchemy import SQLAlchemyModelFactory from {{cookiecutter.app_name}}.user.models import User from {{cookiecutter.app_name}}.database import db +class BaseFactory(SQLAlchemyModelFactory): -class UserFactory(SQLAlchemyModelFactory): class Meta: - model = User + abstract = True sqlalchemy_session = db.session + +class UserFactory(BaseFactory): username = Sequence(lambda n: "user{0}".format(n)) email = Sequence(lambda n: "user{0}@example.com".format(n)) password = PostGenerationMethodCall('set_password', 'example') active = True + + class Meta: + model = User +