Пример #1
0
    def setUp(self):
        self.user = User.objects.create_user("username", "*****@*****.**", "passtest",
                                             first_name='first_name', last_name='last_name')
        self.user.save()
        add_permission(self.user, "is_internship_manager")
        self.person = test_person.create_person_with_user(self.user)
        self.client.force_login(self.user)

        self.cohort = CohortFactory()

        self.student = test_student.create_student("first", "last", "64641200")

        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.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)
Пример #2
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)
Пример #3
0
    def test_find_selectable_by_speciality_and_cohort(self):
        speciality = test_internship_speciality.create_speciality(
            "OTHER", "OTHER", cohort=self.offer.cohort)
        organization = test_organization.create_organization(
            "ORG", "ORG", "02", cohort=self.offer.cohort)
        other_offer = create_specific_internship_offer(
            organization,
            speciality,
            title="other_offer",
            cohort=self.offer.cohort)

        actual = list(
            internship_offer.find_selectable_by_speciality_and_cohort(
                self.offer.speciality, self.offer.cohort))
        self.assertEqual(len(actual), 1)
        self.assertIn(self.offer, actual)

        self.offer.selectable = False
        self.offer.save()
        actual = list(
            internship_offer.find_selectable_by_speciality_and_cohort(
                speciality=self.offer.speciality, cohort=self.offer.cohort))
        self.assertEqual(len(actual), 0)

        actual = list(
            internship_offer.find_selectable_by_speciality_and_cohort(
                speciality, self.offer.cohort))
        self.assertEqual(len(actual), 1)
        self.assertIn(other_offer, actual)
    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)
Пример #5
0
 def test_two_personal_internships_at_most(self):
     organization = test_organization.create_organization(name="Stage personnel")
     speciality = test_internship_speciality.create_speciality(name="Stage personnel",
                                                               acronym="SP")
     offer = test_internship_offer.create_specific_internship_offer(organization, speciality,
                                                                    title="Stage personnel")
     choice_1 = test_internship_choice.create_internship_choice(
         organization, self.student, speciality, self.internship_1
     )
     choice_2 = test_internship_choice.create_internship_choice(
         organization, self.student, speciality, self.internship_2
     )
     selection_url = reverse("select_internship", kwargs={'cohort_id': self.cohort.id})
     self.client.post(selection_url, data={
         '{}-TOTAL_FORMS'.format(self.speciality_2.name): '2',
         '{}-INITIAL_FORMS'.format(self.speciality_2.name): '0',
         '{}-MIN_NUM_FORMS'.format(self.speciality_2.name): '2',
         '{}-MAX_NUM_FORMS'.format(self.speciality_2.name): '2',
         'form-0-offer': str(offer.id),
         'form-0-preference': '1',
         'current_internship'.format(self.speciality_2.name): self.internship_2.id,
     })
     choices = list(mdl_internship_choice.search(student=self.student))
     self.assertEqual(len(choices), 2)
     self.assertIn(choice_1, choices)
     self.assertIn(choice_2, choices)
Пример #6
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())
Пример #7
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)
Пример #8
0
    def test_get_number_first_choice_by_organization(self):
        number_first_choice = list(
            mdl_internship_choice.get_number_first_choice_by_organization(
                self.speciality, self.internship))
        expected = [{
            "organization": self.organization.id,
            "organization__count": 2
        }]
        self.assertEqual(expected, number_first_choice)

        other_organization = test_organization.create_organization(
            reference="10")
        yet_another_student = test_student.create_student("64641201")
        create_internship_choice(other_organization, yet_another_student,
                                 self.speciality, self.internship)
        number_first_choice = list(
            mdl_internship_choice.get_number_first_choice_by_organization(
                self.speciality, self.internship))
        expected = [{
            "organization": self.organization.id,
            "organization__count": 2
        }, {
            "organization": other_organization.id,
            "organization__count": 1
        }]
        self.assertCountEqual(number_first_choice, expected)
        self.assertIn(expected[0], number_first_choice)
        self.assertIn(expected[1], number_first_choice)
    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)
Пример #10
0
    def setUpTestData(cls):
        cls.user = User.objects.create_user("username",
                                            "*****@*****.**",
                                            "passtest",
                                            first_name='first_name',
                                            last_name='last_name')
        cls.user.save()
        add_permission(cls.user, "is_internship_manager")
        cls.person = test_person.create_person_with_user(cls.user)

        cls.cohort = CohortFactory()

        cls.student = test_student.create_student("first", "last", "64641200")

        cls.speciality_1 = test_internship_speciality.create_speciality(
            name="urgence", cohort=cls.cohort)
        cls.speciality_2 = test_internship_speciality.create_speciality(
            name="chirurgie", cohort=cls.cohort)

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

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

        cls.offer_5 = test_internship_offer.create_specific_internship_offer(
            cls.organization_1, cls.speciality_2, cohort=cls.cohort)
        cls.offer_6 = test_internship_offer.create_specific_internship_offer(
            cls.organization_5, cls.speciality_2, cohort=cls.cohort)
Пример #11
0
def create_internship_student_affectation_stat(student):
    organization = test_organization.create_organization()
    speciality = test_internship_speciality.create_speciality()
    period = create_period()

    student_affectation = mdl_student_affectation.InternshipStudentAffectationStat(student=student, period=period,
                                                                                   organization=organization,
                                                                                   speciality=speciality,
                                                                                   cost=10)
    student_affectation.save()
    return student_affectation
Пример #12
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)
Пример #13
0
def create_internship_offer(cohort=None):
    if cohort == None:
        cohort = CohortFactory()
    organization = test_organization.create_organization()
    speciality = test_internship_speciality.create_speciality()
    offer = internship_offer.InternshipOffer(speciality=speciality,
                                             organization=organization,
                                             title="offer_test",
                                             cohort=cohort,
                                             maximum_enrollments=20,
                                             master="Dr. Test")
    offer.save()
    return offer
Пример #14
0
def create_internship_offer(cohort=None):
    if cohort is None:
        cohort = CohortFactory()
    organization = test_organization.create_organization(cohort=cohort)
    speciality = test_internship_speciality.create_speciality(cohort=cohort)

    return OfferFactory(
        speciality=speciality,
        organization=organization,
        title="offer_test",
        maximum_enrollments=20,
        cohort=cohort,
    )
Пример #15
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,
                          })
Пример #16
0
    def setUp(self):
        self.user = User.objects.create_user("username", "*****@*****.**", "passtest",
                                             first_name='first_name', last_name='last_name')
        self.user.save()
        add_permission(self.user, "is_internship_manager")
        self.person = test_person.create_person_with_user(self.user)

        self.cohort = CohortFactory()

        self.client.force_login(self.user)

        self.speciality = test_internship_speciality.create_speciality(name="urgence", cohort=self.cohort)
        self.organization = test_organization.create_organization(reference="01", cohort=self.cohort)
        self.offer = test_internship_offer.create_specific_internship_offer(self.organization, self.speciality, cohort=self.cohort)

        MAX_PERIOD = 12
        for period in range(1, MAX_PERIOD + 1):
            test_period.create_period("P%d" % period, cohort=self.cohort)
Пример #17
0
 def test_replace_previous_choices(self):
     previous_choice = test_internship_choice.create_internship_choice(
         test_organization.create_organization(),
         self.student, self.speciality_2, self.internship_1
     )
     choices = list(mdl_internship_choice.search(student=self.student, speciality=self.speciality_2))
     self.assertEqual(len(choices), 1)
     selection_url = reverse("select_internship", kwargs={'cohort_id': self.cohort.id})
     self.client.post(selection_url, data={
         '{}-TOTAL_FORMS'.format(self.speciality_2.name): '2',
         '{}-INITIAL_FORMS'.format(self.speciality_2.name): '0',
         '{}-MIN_NUM_FORMS'.format(self.speciality_2.name): '2',
         '{}-MAX_NUM_FORMS'.format(self.speciality_2.name): '2',
         '{}-0-offer'.format(self.speciality_2.name): str(self.offer_5.id),
         '{}-0-preference'.format(self.speciality_2.name): '1',
         '{}-1-offer'.format(self.speciality_2.name): str(self.offer_6.id),
         '{}-1-preference'.format(self.speciality_2.name): '0',
         'current_internship'.format(self.speciality_2.name): self.internship_2.id,
     })
     choices = list(mdl_internship_choice.search(student=self.student, speciality=self.speciality_2))
     self.assertEqual(len(choices), 1)
     self.assertNotEqual(previous_choice, choices[0])
Пример #18
0
    def setUpTestData(cls):
        cls.user = User.objects.create_user("username",
                                            "*****@*****.**",
                                            "passtest",
                                            first_name='first_name',
                                            last_name='last_name')
        cls.user.save()
        add_permission(cls.user, "is_internship_manager")
        cls.person = test_person.create_person_with_user(cls.user)

        cls.cohort = CohortFactory()

        cls.speciality = test_internship_speciality.create_speciality(
            name="urgence", cohort=cls.cohort)
        cls.organization = test_organization.create_organization(
            reference="01", cohort=cls.cohort)
        cls.offer = test_internship_offer.create_specific_internship_offer(
            cls.organization, cls.speciality, cohort=cls.cohort)

        MAX_PERIOD = 12
        for period in range(1, MAX_PERIOD + 1):
            test_period.create_period("P%d" % period, cohort=cls.cohort)

        cls.internship_offer = OfferFactory(cohort=cls.cohort)