You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
763 B
31 lines
763 B
# -*- coding: utf-8 -*-
|
|
"""Factories to help in tests."""
|
|
from factory import PostGenerationMethodCall, Sequence
|
|
from factory.alchemy import SQLAlchemyModelFactory
|
|
|
|
from harambee_led_bord.database import db
|
|
from harambee_led_bord.user.models import User
|
|
|
|
|
|
class BaseFactory(SQLAlchemyModelFactory):
|
|
"""Base factory."""
|
|
|
|
class Meta:
|
|
"""Factory configuration."""
|
|
|
|
abstract = True
|
|
sqlalchemy_session = db.session
|
|
|
|
|
|
class UserFactory(BaseFactory):
|
|
"""User factory."""
|
|
|
|
username = Sequence(lambda n: f"user{n}")
|
|
email = Sequence(lambda n: f"user{n}@example.com")
|
|
password = PostGenerationMethodCall("set_password", "example")
|
|
active = True
|
|
|
|
class Meta:
|
|
"""Factory configuration."""
|
|
|
|
model = User
|
|
|