From 1aa6737cd0ed632f03ebfe034b2ba17899d19c3a Mon Sep 17 00:00:00 2001 From: Mo8it Date: Wed, 14 Jul 2021 04:24:32 +0200 Subject: [PATCH] Use customInit in testDB.py --- testDB.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/testDB.py b/testDB.py index 00ddf11..e02d463 100644 --- a/testDB.py +++ b/testDB.py @@ -46,20 +46,20 @@ with app.app_context(): db.session.add(student2) db.session.add(student3) - g1 = Group(number=1, program=program1) - g2 = Group(number=1, program=program2) - - db.session.add(g1) - db.session.add(g2) - - ps1 = PartStudent(student=student1, part=part1, group=g1) - ps2 = PartStudent(student=student2, part=part1, group=g1) - ps3 = PartStudent(student=student3, part=part2, group=g2) + ps1 = PartStudent.customInit(student=student1, part=part1) + ps2 = PartStudent.customInit(student=student2, part=part1) + ps3 = PartStudent.customInit(student=student3, part=part2) db.session.add(ps1) db.session.add(ps2) db.session.add(ps3) + g1 = Group.customInit(part_students=[ps1, ps2]) + g2 = Group.customInit(part_students=[ps3]) + + db.session.add(g1) + db.session.add(g2) + ex1 = Experiment( number=1, program=program1, @@ -95,8 +95,8 @@ with app.app_context(): db.session.add(sx1) db.session.add(sx2) - gx1 = GroupExperiment(semester_experiment=sx1, group=g1) - gx2 = GroupExperiment(semester_experiment=sx2, group=g2) + gx1 = GroupExperiment.customInit(semester_experiment=sx1, group=g1) + gx2 = GroupExperiment.customInit(semester_experiment=sx2, group=g2) db.session.add(gx1) db.session.add(gx2) @@ -124,18 +124,10 @@ with app.app_context(): db.session.add(as1) db.session.add(as2) - ap1 = Appointment(date=date(2021, 3, 21), special=True, group_experiment=gx1, assistant=as1) - ap2 = Appointment(date=date(2021, 3, 22), special=True, group_experiment=gx2, assistant=as2) + ap1 = Appointment.customInit(date=date(2021, 3, 21), special=True, assistant=as1, group_experiment=gx1) + ap2 = Appointment.customInit(date=date(2021, 3, 22), special=True, assistant=as2, group_experiment=gx2) db.session.add(ap1) db.session.add(ap2) - em1 = ExperimentMark(oral_mark=11, protocol_mark=14, part_student=ps1, group_experiment=gx1, assistant=as1) - em2 = ExperimentMark(oral_mark=12, protocol_mark=14, part_student=ps2, group_experiment=gx1, assistant=as1) - em3 = ExperimentMark(oral_mark=13, protocol_mark=14, part_student=ps3, group_experiment=gx2, assistant=as2) - - db.session.add(em1) - db.session.add(em2) - db.session.add(em3) - db.session.commit()