2023-01-10 00:17:25 +01:00
|
|
|
import datetime
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
from factory import Sequence, alchemy
|
2023-01-06 22:35:47 +01:00
|
|
|
from factory.faker import Faker
|
2023-01-14 17:38:03 +01:00
|
|
|
from factory.fuzzy import FuzzyDateTime, FuzzyInteger
|
2023-01-06 22:35:47 +01:00
|
|
|
|
2023-01-09 22:32:58 +01:00
|
|
|
from app.dependencies import db
|
2023-01-10 00:17:25 +01:00
|
|
|
from app.examination_schedule.models import ExaminationSchedule
|
2023-01-14 17:38:03 +01:00
|
|
|
from app.project_supervisor.models import ProjectSupervisor, YearGroupProjectSupervisors
|
|
|
|
from app.students.models import Group, Student, YearGroupStudents
|
2023-01-06 22:35:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ProjectSupervisorFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = ProjectSupervisor
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
first_name = Faker("first_name")
|
|
|
|
last_name = Faker("last_name")
|
|
|
|
email = Faker("email")
|
2023-01-06 22:35:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
class YearGroupProjectSupervisorsFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = YearGroupProjectSupervisors
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
|
|
|
limit_group = 4
|
|
|
|
|
2023-01-08 17:15:02 +01:00
|
|
|
|
2023-01-06 22:35:47 +01:00
|
|
|
class GroupFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Group
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
name = Sequence(lambda n: f"Group-{n}")
|
2023-01-06 22:35:47 +01:00
|
|
|
points_for_first_term = FuzzyInteger(1, 5)
|
|
|
|
points_for_second_term = FuzzyInteger(1, 5)
|
|
|
|
|
2023-01-08 17:15:02 +01:00
|
|
|
|
|
|
|
class StudentFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Student
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
first_name = Faker("first_name")
|
|
|
|
last_name = Faker("last_name")
|
|
|
|
email = Faker("email")
|
2023-01-08 17:15:02 +01:00
|
|
|
index = Sequence(lambda n: 400_000 + n)
|
|
|
|
|
|
|
|
|
|
|
|
class YearGroupStudentsFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = YearGroupStudents
|
|
|
|
sqlalchemy_session = db.session
|
2023-01-10 00:17:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ExaminationScheduleFactory(alchemy.SQLAlchemyModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = ExaminationSchedule
|
|
|
|
sqlalchemy_session = db.session
|
|
|
|
|
2023-01-14 17:38:03 +01:00
|
|
|
title = Sequence(lambda n: f"Examination schedule {n}")
|
2023-01-10 00:17:25 +01:00
|
|
|
duration_time = 30
|
2023-01-14 17:38:03 +01:00
|
|
|
start_date = FuzzyDateTime(
|
|
|
|
datetime.datetime(2020, 1, 1, tzinfo=datetime.timezone.utc),
|
|
|
|
datetime.datetime(2020, 1, 5, tzinfo=datetime.timezone.utc),
|
|
|
|
)
|
|
|
|
end_date = FuzzyDateTime(
|
|
|
|
datetime.datetime(2020, 1, 10, tzinfo=datetime.timezone.utc),
|
|
|
|
datetime.datetime(2020, 1, 20, tzinfo=datetime.timezone.utc),
|
|
|
|
)
|