def setUp(self):
        self.organization = test_organization.create_organization()
        self.student = test_student.create_student(first_name="first",
                                                   last_name="last",
                                                   registration_id="64641200")
        self.other_student = test_student.create_student(
            first_name="first", last_name="last", registration_id="606012")
        self.cohort = CohortFactory()
        self.speciality = test_internship_speciality.create_speciality(
            cohort=self.cohort)
        self.internship = InternshipFactory(cohort=self.cohort)
        self.other_internship = InternshipFactory(cohort=self.cohort)
        self.student_information = test_internship_student_information.create_student_information(
            person=self.student.person, cohort=self.cohort)
        self.other_student_information = test_internship_student_information.create_student_information(
            person=self.other_student.person, cohort=self.cohort)

        self.choice_1 = create_internship_choice(
            self.organization,
            self.student,
            self.speciality,
            internship=self.other_internship)
        self.choice_2 = create_internship_choice(self.organization,
                                                 self.student,
                                                 self.speciality,
                                                 internship=self.internship)
        self.choice_3 = create_internship_choice(
            self.organization,
            self.other_student,
            self.speciality,
            internship=self.other_internship)
    def setUpTestData(cls):
        cls.organization = test_organization.create_organization()
        cls.student = test_student.create_student(first_name="first",
                                                  last_name="last",
                                                  registration_id="64641200")
        cls.other_student = test_student.create_student(
            first_name="first", last_name="last", registration_id="606012")
        cls.cohort = CohortFactory()
        cls.speciality = test_internship_speciality.create_speciality(
            cohort=cls.cohort)
        cls.internship = InternshipFactory(cohort=cls.cohort)
        cls.other_internship = InternshipFactory(cohort=cls.cohort)
        cls.student_information = test_internship_student_information.create_student_information(
            person=cls.student.person, cohort=cls.cohort)
        cls.other_student_information = test_internship_student_information.create_student_information(
            person=cls.other_student.person, cohort=cls.cohort)

        cls.choice_1 = create_internship_choice(
            cls.organization,
            cls.student,
            cls.speciality,
            internship=cls.other_internship)
        cls.choice_2 = create_internship_choice(cls.organization,
                                                cls.student,
                                                cls.speciality,
                                                internship=cls.internship)
        cls.choice_3 = create_internship_choice(
            cls.organization,
            cls.other_student,
            cls.speciality,
            internship=cls.other_internship)
예제 #3
0
    def setUpTestData(cls):
        cls.user = User.objects.create_user('demo', '*****@*****.**',
                                            'passtest')
        permission = Permission.objects.get(codename='is_internship_manager')
        cls.user.user_permissions.add(permission)
        cls.cohort = CohortFactory()
        cls.organization = OrganizationFactory(cohort=cls.cohort)
        cls.specialty = SpecialtyFactory(mandatory=True, cohort=cls.cohort)
        cls.offer = OfferFactory(cohort=cls.cohort,
                                 organization=cls.organization,
                                 speciality=cls.specialty)
        students = [StudentFactory() for _ in range(0, 4)]
        mandatory_internship = InternshipFactory(cohort=cls.cohort,
                                                 speciality=cls.specialty)
        non_mandatory_internship = InternshipFactory(cohort=cls.cohort)

        for internship in [mandatory_internship, non_mandatory_internship]:
            for choice in CHOICES:
                create_internship_choice(organization=cls.organization,
                                         student=students[0],
                                         speciality=cls.specialty,
                                         choice=choice,
                                         internship=internship)
        for student in students[1:]:
            create_internship_choice(organization=cls.organization,
                                     student=student,
                                     speciality=cls.specialty,
                                     choice=random.choice([2, 3, 4]),
                                     internship=mandatory_internship)
        cls.url = reverse('internships', kwargs={
            'cohort_id': cls.cohort.id,
        })
예제 #4
0
    def setUp(self) -> None:
        self.organization = test_organization.create_organization()
        self.student = test_student.create_student("64641200")
        self.other_student = test_student.create_student("60601200")
        self.speciality = test_internship_speciality.create_speciality()
        self.other_speciality = test_internship_speciality.create_speciality()
        self.internship = InternshipFactory(speciality=self.speciality)
        self.other_internship = InternshipFactory(speciality=self.speciality)

        self.choice_1 = create_internship_choice(
            self.organization,
            self.student,
            self.other_speciality,
            internship=self.other_internship)
        self.choice_2 = create_internship_choice(self.organization,
                                                 self.student,
                                                 self.speciality,
                                                 internship=self.internship)
        self.choice_3 = create_internship_choice(
            self.organization,
            self.other_student,
            self.other_speciality,
            internship=self.other_internship)
        self.choice_4 = create_internship_choice(self.organization,
                                                 self.other_student,
                                                 self.speciality,
                                                 internship=self.internship)
예제 #5
0
    def setUp(self):
        self.student = StudentFactory()
        self.user = self.student.person.user
        add_permission(self.user, "can_access_internship")

        self.cohort = CohortFactory()
        self.student_information = test_internship_student_information.create_student_information(
            self.user,
            self.cohort,
            self.student.person
        )

        self.speciality_1 = test_internship_speciality.create_speciality(name="urgence", cohort=self.cohort)
        self.speciality_2 = test_internship_speciality.create_speciality(name="chirurgie", cohort=self.cohort)
        self.internship_1 = InternshipFactory(
            name=self.speciality_1.name,
            cohort=self.cohort,
            speciality=self.speciality_1
        )
        self.internship_2 = InternshipFactory(
            name=self.speciality_2.name,
            cohort=self.cohort,
            speciality=self.speciality_2
        )

        self.organization_1 = test_organization.create_organization(reference="01", cohort=self.cohort)
        self.organization_2 = test_organization.create_organization(reference="02", cohort=self.cohort)
        self.organization_3 = test_organization.create_organization(reference="03", cohort=self.cohort)
        self.organization_4 = test_organization.create_organization(reference="04", cohort=self.cohort)
        self.organization_5 = test_organization.create_organization(reference="05", cohort=self.cohort)

        self.offer_1 = test_internship_offer.create_specific_internship_offer(
            self.organization_1, self.speciality_1,
            cohort=self.cohort
        )
        self.offer_2 = test_internship_offer.create_specific_internship_offer(
            self.organization_2, self.speciality_1,
            cohort=self.cohort
        )
        self.offer_3 = test_internship_offer.create_specific_internship_offer(
            self.organization_3, self.speciality_1,
            cohort=self.cohort
        )
        self.offer_4 = test_internship_offer.create_specific_internship_offer(
            self.organization_4, self.speciality_1,
            cohort=self.cohort
        )

        self.offer_5 = test_internship_offer.create_specific_internship_offer(
            self.organization_1, self.speciality_2,
            cohort=self.cohort
        )
        self.offer_6 = test_internship_offer.create_specific_internship_offer(
            self.organization_5, self.speciality_2,
            cohort=self.cohort
        )

        self.client.force_login(self.user)
예제 #6
0
    def setUp(self):
        self.cohort = CohortFactory()
        organization = test_organization.create_organization(
            cohort=self.cohort)
        self.student_1 = test_student.create_student(
            first_name="first", last_name="last", registration_id="64641200")
        self.student_2 = test_student.create_student(first_name="first",
                                                     last_name="last",
                                                     registration_id="606012")
        speciality = test_internship_speciality.create_speciality(
            cohort=self.cohort)

        self.internship = InternshipFactory(cohort=self.cohort)
        self.internship_2 = InternshipFactory(cohort=self.cohort)
        self.internship_3 = InternshipFactory(cohort=self.cohort)
        self.internship_4 = InternshipFactory(cohort=self.cohort)

        self.choice_1 = test_internship_choice.create_internship_choice(
            organization,
            self.student_1,
            speciality,
            internship=self.internship)
        self.choice_2 = test_internship_choice.create_internship_choice(
            organization,
            self.student_1,
            speciality,
            internship=self.internship_2)
        self.choice_3 = test_internship_choice.create_internship_choice(
            organization,
            self.student_1,
            speciality,
            internship=self.internship_3)
        self.choice_4 = test_internship_choice.create_internship_choice(
            organization,
            self.student_1,
            speciality,
            internship=self.internship_4)

        self.choice_5 = test_internship_choice.create_internship_choice(
            organization,
            self.student_2,
            speciality,
            internship=self.internship)
        self.choice_6 = test_internship_choice.create_internship_choice(
            organization,
            self.student_2,
            speciality,
            internship=self.internship_2)
        self.choice_7 = test_internship_choice.create_internship_choice(
            organization,
            self.student_2,
            speciality,
            internship=self.internship_3)
예제 #7
0
    def setUpTestData(cls):
        cls.cohort = CohortFactory()
        organization = test_organization.create_organization(cohort=cls.cohort)
        cls.student_1 = test_student.create_student(first_name="first",
                                                    last_name="last",
                                                    registration_id="64641200")
        cls.student_2 = test_student.create_student(first_name="first",
                                                    last_name="last",
                                                    registration_id="606012")
        speciality = test_internship_speciality.create_speciality(
            cohort=cls.cohort)

        cls.internship = InternshipFactory(cohort=cls.cohort)
        cls.internship_2 = InternshipFactory(cohort=cls.cohort)
        cls.internship_3 = InternshipFactory(cohort=cls.cohort)
        cls.internship_4 = InternshipFactory(cohort=cls.cohort)

        cls.choice_1 = create_internship_choice(organization,
                                                cls.student_1,
                                                speciality,
                                                internship=cls.internship)
        cls.choice_2 = create_internship_choice(organization,
                                                cls.student_1,
                                                speciality,
                                                internship=cls.internship_2)
        cls.choice_3 = create_internship_choice(organization,
                                                cls.student_1,
                                                speciality,
                                                internship=cls.internship_3)
        cls.choice_4 = create_internship_choice(organization,
                                                cls.student_1,
                                                speciality,
                                                internship=cls.internship_4)
        cls.choice_5 = create_internship_choice(organization,
                                                cls.student_2,
                                                speciality,
                                                internship=cls.internship)
        cls.choice_6 = create_internship_choice(organization,
                                                cls.student_2,
                                                speciality,
                                                internship=cls.internship_2)
        cls.choice_7 = create_internship_choice(organization,
                                                cls.student_2,
                                                speciality,
                                                internship=cls.internship_3)
        cls.url = reverse(internships_student_resume,
                          kwargs={
                              'cohort_id': cls.cohort.id,
                          })
예제 #8
0
def _make_shortage_scenario(cls):
    '''Make scenario for internship offer with not enough places for student'''
    cls.organizations.append(cls.hospital_error)
    specialty_with_offer_shortage = SpecialtyFactory(mandatory=True,
                                                     cohort=cls.cohort)
    internship_with_offer_shortage = InternshipFactory(
        cohort=cls.cohort,
        name=specialty_with_offer_shortage.name,
        speciality=specialty_with_offer_shortage,
        position=-1)
    for organization in cls.organizations:
        number_places = 999 if organization is cls.hospital_error else 0
        shortage_offer = OfferFactory(cohort=cls.cohort,
                                      organization=organization,
                                      speciality=specialty_with_offer_shortage)
        for period in cls.periods:
            PeriodInternshipPlacesFactory(period=period,
                                          internship_offer=shortage_offer,
                                          number_places=number_places)
    cls.organizations.remove(cls.hospital_error)
    unlucky_student = random.choice(cls.students)
    available_organizations = cls.organizations.copy()
    for choice in range(1, 5):
        organization = random.choice(available_organizations)
        available_organizations.remove(organization)
        create_internship_choice(
            organization=organization,
            student=unlucky_student,
            internship=internship_with_offer_shortage,
            choice=choice,
            speciality=specialty_with_offer_shortage,
        )
    return internship_with_offer_shortage, unlucky_student
예제 #9
0
    def test_replace_previous_choices(self):
        internship = InternshipFactory(cohort=self.cohort)
        previous_choice = test_internship_choice.create_internship_choice(
            test_organization.create_organization(), self.student,
            self.speciality_1, internship)
        kwargs = {
            'cohort_id': self.cohort.id,
            'internship_id': internship.id,
            'speciality_id': self.speciality_2.id,
            'student_id': self.student.id
        }
        selection_url = reverse("specific_internship_student_modification",
                                kwargs=kwargs)

        data = self.generate_form([
            (self.offer_5, 1, True),
            (self.offer_6, 0, False),
        ])

        response = self.client.post(selection_url, data=data)
        self.assertEqual(response.status_code, 200)

        qs = mdl_internship_choice.search_by_student_or_choice(
            student=self.student)

        self.assertEqual(qs.count(), 1)
        self.assertNotEqual(previous_choice, qs.first())
예제 #10
0
    def test_with_one_choice(self):
        internship = InternshipFactory(cohort=self.cohort)
        kwargs = {
            'cohort_id': self.cohort.id,
            'internship_id': internship.id,
            'speciality_id': self.speciality_2.id,
            'student_id': self.student.id
        }
        selection_url = reverse("specific_internship_student_modification",
                                kwargs=kwargs)

        data = self.generate_form([(self.offer_5, 1, True),
                                   (self.offer_6, 0, False)])

        response = self.client.post(selection_url, data=data)
        self.assertEqual(response.status_code, 200)

        qs = mdl_internship_choice.search_by_student_or_choice(
            student=self.student)
        self.assertEqual(qs.count(), 1)

        choice = qs.first()
        self.assertEqual(choice.organization, self.organization_1)
        self.assertEqual(choice.speciality, self.speciality_2)
        self.assertEqual(choice.internship, internship)
        self.assertEqual(choice.choice, 1)
        self.assertTrue(choice.priority)
예제 #11
0
    def test_with_multiple_choice(self):
        internship = InternshipFactory(cohort=self.cohort)
        kwargs = {
            'cohort_id': self.cohort.id,
            'internship_id': internship.id,
            'speciality_id': self.speciality_1.id,
            'student_id': self.student.id
        }
        selection_url = reverse("specific_internship_student_modification", kwargs=kwargs)

        data = self.generate_form([
            (self.offer_1, 1, False),
            (self.offer_2, 2, False),
            (self.offer_3, 3, False),
            (self.offer_4, 4, False),
        ])

        response = self.client.post(selection_url, data=data)
        self.assertEqual(response.status_code, 200)

        qs = mdl_internship_choice.search_by_student_or_choice(student=self.student)
        self.assertEqual(qs.count(), 4)

        data = self.generate_form([
            (self.offer_1, 1, False),
            (self.offer_2, 0, False),
            (self.offer_3, 2, False),
            (self.offer_4, 0, False),
        ])

        self.client.post(selection_url, data=data)

        qs = mdl_internship_choice.search_by_student_or_choice(student=self.student)
        self.assertEqual(qs.count(), 2)
예제 #12
0
 def setUpTestData(cls):
     cls.student = StudentFactory()
     cls.user = cls.student.person.user
     cls.cohort = CohortFactory()
     cls.internship = InternshipFactory(cohort=cls.cohort)
     cls.student_information = test_internship_student_information.create_student_information(cls.user,
                                                                                              cls.cohort,
                                                                                              cls.student.person)
     add_permission(cls.user, "can_access_internship")
예제 #13
0
def _create_mandatory_internships(cls):
    mandatory_specialties = [
        SpecialtyFactory(mandatory=True)
        for _ in range(0, N_MANDATORY_INTERNSHIPS)
    ]
    mandatory_internships = [
        InternshipFactory(cohort=cls.cohort, name=spec.name, speciality=spec)
        for spec in mandatory_specialties
    ]
    return mandatory_internships, mandatory_specialties
예제 #14
0
    def test_build_with_choices(self):
        cohort = CohortFactory()
        internship = InternshipFactory(cohort=cohort)
        self.choice = create_internship_choice(self.organization, self.student, self.specialty, internship=internship)
        student_choices = [self.choice,]
        affectation = internship_student_affectation_stat.build(self.student, self.organization, self.specialty,
                                                                self.period, student_choices)

        self.assertEquals(affectation.cost, 0)
        self.assertEquals(affectation.choice, self.choice.choice)
예제 #15
0
def _create_non_mandatory_internships(cls):
    non_mandatory_specialties = [
        SpecialtyFactory(mandatory=False)
        for _ in range(0, N_NON_MANDATORY_INTERNSHIPS)
    ]
    non_mandatory_internships = [
        InternshipFactory(cohort=cls.cohort,
                          name="Chosen internship {}".format(i + 1))
        for i in range(0, 4)
    ]
    return non_mandatory_internships, non_mandatory_specialties
예제 #16
0
 def setUpTestData(cls):
     cls.user = UserFactory()
     cls.student = StudentFactory(person__user=cls.user)
     add_permission(cls.student.person.user, "can_access_internship")
     cls.cohort = CohortFactory()
     cls.student_information = test_internship_student_information.create_student_information(
         cls.user,
         cls.cohort,
         cls.student.person
     )
     cls.selective_internship = InternshipFactory(
         name='Selective internship',
         cohort=cls.cohort,
         speciality=None
     )
     cls.specialty = test_internship_speciality.create_speciality(name="specialty", cohort=cls.cohort)
예제 #17
0
 def test_permute_exchanged_affectation_information(self):
     specialty = SpecialtyFactory()
     period = PeriodFactory()
     internship = InternshipFactory(speciality=specialty)
     defavored_affectation = StudentAffectationStatFactory(
         speciality=specialty,
         organization=self.organizations[-1],
         period=period,
         internship=internship,
         cost=10,
         choice="I")
     favored_affectation = StudentAffectationStatFactory(
         speciality=specialty,
         organization=self.organizations[1],
         period=period,
         internship=internship,
         cost=0)
     self.affectations = InternshipStudentAffectationStat.objects.all()
     for choice, organization in enumerate(self.organizations[:4], start=1):
         create_internship_choice(
             organization=organization,
             student=defavored_affectation.student,
             internship=internship,
             choice=choice,
             speciality=specialty,
         )
     _permute_affectations(self, [defavored_affectation],
                           [favored_affectation],
                           InternshipChoice.objects.all())
     InternshipStudentAffectationStat.objects.bulk_update(
         self.affectations, fields=['organization'])
     self.assertEqual(
         self.affectations.get(
             student=defavored_affectation.student).organization,
         self.organizations[1])
     self.assertEqual(
         self.affectations.get(
             student=favored_affectation.student).organization,
         self.organizations[-1])
예제 #18
0
 def setUpTestData(cls):
     cls.cohort = CohortFactory()
     cls.period = PeriodFactory(name='P1',
                                date_end=date.today() -
                                relativedelta(months=2),
                                cohort=cls.cohort)
     cls.other_period = PeriodFactory(
         name='P2',
         date_end=date.today() - relativedelta(months=1),
         cohort=cls.cohort,
     )
     cls.xlsfile = SimpleUploadedFile(
         name='upload.xls',
         content=str.encode('test'),
         content_type="application/vnd.ms-excel",
     )
     cls.xlsxfile = SimpleUploadedFile(
         name='upload.xlsx',
         content=str.encode('test'),
         content_type=
         "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
     )
     cls.students = [
         InternshipStudentInformationFactory(cohort=cls.cohort)
         for _ in range(11)
     ]
     cls.mandatory_internship = InternshipFactory(
         cohort=cls.cohort, speciality=SpecialtyFactory(cohort=cls.cohort))
     cls.long_internship = InternshipFactory(cohort=cls.cohort,
                                             speciality=SpecialtyFactory(
                                                 cohort=cls.cohort,
                                                 sequence=1))
     cls.chosen_internship = InternshipFactory(cohort=cls.cohort,
                                               speciality=None)
     internships = [
         cls.mandatory_internship, cls.long_internship,
         cls.chosen_internship
     ]
     periods = [cls.period
                ] + [PeriodFactory(cohort=cls.cohort) for _ in range(2)]
     for student_info in cls.students:
         student = StudentFactory(person=student_info.person)
         for index, internship in enumerate(internships):
             StudentAffectationStatFactory(
                 student=student,
                 internship=internship,
                 speciality=internship.speciality
                 if internship.speciality else SpecialtyFactory(),
                 period=periods[index])
         ScoreFactory(student_affectation__student=student,
                      student_affectation__period=cls.period,
                      APD_1='A',
                      validated=True)
     for apd in range(1, APD_NUMBER):
         ScoreMappingFactory(period=cls.period,
                             cohort=cls.cohort,
                             score_A=20,
                             score_B=15,
                             score_C=10,
                             score_D=0,
                             apd=apd)
     cls.unused_period = PeriodFactory(name="P99",
                                       cohort=cls.cohort,
                                       date_end=date.today() +
                                       relativedelta(months=+2))
     cls.user = User.objects.create_user('demo', '*****@*****.**',
                                         'passtest')
     permission = Permission.objects.get(codename='is_internship_manager')
     cls.user.user_permissions.add(permission)
     cls.all_apds_validated = {
         'APD_{}'.format(i): 'D'
         for i in range(1, APD_NUMBER + 1)
     }