Exemple #1
0
    def test_search_learning_units_on_acronym(self):
        form_data = {
            "acronym": self.external_lu_1.learning_unit_year.acronym,
        }

        external_filter = ExternalLearningUnitFilter(form_data)
        self.assertTrue(external_filter.is_valid())
        self.assertCountEqual(external_filter.qs,
                              [self.external_lu_1.learning_unit_year])
Exemple #2
0
    def test_search_learning_units_by_city(self):
        form_data = {
            "country":
            self.external_lu_1.learning_unit_year.campus.organization.country.
            id,
            "city":
            NAMEN,
        }

        external_filter = ExternalLearningUnitFilter(form_data)
        self.assertTrue(external_filter.is_valid())
        self.assertCountEqual(external_filter.qs,
                              [self.external_lu_1.learning_unit_year])
Exemple #3
0
 def test_assert_ignore_external_learning_units_of_type_mobility(self):
     original_count = LearningUnitYear.objects.filter(
         externallearningunityear__co_graduation=True,
         externallearningunityear__mobility=False).count()
     ExternalLearningUnitYearFactory(
         learning_unit_year__academic_year=self.academic_year,
         mobility=True,
         co_graduation=False,
         learning_unit_year__acronym="XTEST1234",
     )
     form_data = {
         "academic_year": self.academic_year.id,
     }
     external_filter = ExternalLearningUnitFilter(form_data)
     self.assertTrue(external_filter.is_valid())
     self.assertEqual(external_filter.qs.count(), original_count)
Exemple #4
0
    def test_search_on_external_title(self):
        ExternalLearningUnitYearFactory(
            learning_unit_year__academic_year=self.academic_years[0],
            learning_unit_year__learning_container_year__container_type=
            learning_container_year_types.EXTERNAL,
            learning_unit_year__learning_container_year__common_title=TITLE,
        )

        self.data.update({
            "academic_year_id": str(self.academic_years[0].id),
            "container_type": learning_container_year_types.EXTERNAL,
            "title": TITLE
        })

        learning_unit_filter = ExternalLearningUnitFilter(self.data)
        self.assertTrue(learning_unit_filter.is_valid())
        self.assertEqual(learning_unit_filter.qs.count(), 1)
Exemple #5
0
    def test_dropdown_init(self):
        country = CountryFactory()

        organization_1 = OrganizationFactory(name="organization 1")
        organization_2 = OrganizationFactory(name="organization 2")
        organization_3 = OrganizationFactory(name="organization 3")

        OrganizationAddressFactory(organization=organization_1,
                                   country=country,
                                   city=NAMUR)
        OrganizationAddressFactory(organization=organization_2,
                                   country=country,
                                   city=NAMUR)

        OrganizationAddressFactory(organization=organization_3,
                                   country=country,
                                   city=CINEY)

        CampusFactory(organization=organization_1)
        campus_2 = CampusFactory(organization=organization_1)
        campus_3 = CampusFactory(organization=organization_2)

        form = ExternalLearningUnitFilter({
            'city': NAMUR,
            'country': country,
            "campus": campus_2
        }).form
        campus_form_choices = list(form.fields["campus"].choices)
        self.assertEqual(campus_form_choices[0], ('', '---------'))
        self.assertEqual(campus_form_choices[1][1], 'organization 1')
        self.assertEqual(campus_form_choices[2],
                         (campus_3.id, 'organization 2'))

        city_form_choices = list(form.fields['city'].choices)
        self.assertEqual(city_form_choices, [('', '---------'), (CINEY, CINEY),
                                             (NAMUR, NAMUR)])