2022-06-10 17:53:32 +02:00
|
|
|
from factory import alchemy, Sequence
|
2022-06-07 19:27:13 +02:00
|
|
|
from factory.faker import Faker
|
|
|
|
from factory.fuzzy import FuzzyInteger, FuzzyChoice
|
|
|
|
|
|
|
|
from .dependencies import db
|
2022-06-10 17:53:32 +02:00
|
|
|
from .students.models import Student, Group
|
|
|
|
from .project_supervisor.models import ProjectSupervisor
|
2022-06-07 19:27:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ProjectSupervisorFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = ProjectSupervisor
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
|
|
|
first_name = Faker('first_name')
|
|
|
|
last_name = Faker('last_name')
|
|
|
|
email = Faker('email')
|
|
|
|
limit_group = 4 # FuzzyInteger(3, 5)
|
|
|
|
count_groups = 4
|
2022-06-12 15:38:44 +02:00
|
|
|
mode = 0
|
2022-06-07 19:27:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
class GroupFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Group
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
|
|
|
name = Sequence(lambda n: f'Group-{n}')
|
2022-06-11 12:53:55 +02:00
|
|
|
points_for_first_term = FuzzyInteger(1, 5)
|
|
|
|
points_for_second_term = FuzzyInteger(1, 5)
|
2022-06-07 19:27:13 +02:00
|
|
|
# project_supervisor = RelatedFactory(ProjectSupervisorFactory, 'project_supervisor')
|
|
|
|
|
|
|
|
|
|
|
|
class StudentFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Student
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
|
|
|
first_name = Faker('first_name')
|
|
|
|
last_name = Faker('last_name')
|
|
|
|
email = Faker('email')
|
|
|
|
index = Sequence(lambda n: 400_000 + n)
|
|
|
|
# group = RelatedFactory(GroupFactory)
|
|
|
|
mode = FuzzyChoice([True, False])
|