Ejemplo n.º 1
0
    def test_with_faculty_borrowing_set(self):
        qs = LearningUnitYear.objects.filter(pk__in=[
            luy.pk
            for luy in self.luys_in_different_faculty_than_education_group
        ])
        group = GroupElementYear.objects.get(
            child_leaf=self.luys_in_different_faculty_than_education_group[0])
        entity = OfferYearEntity.objects.get(
            education_group_year=group.parent).entity
        result = list(
            filter_is_borrowed_learning_unit_year(
                qs, self.academic_year.start_date,
                faculty_borrowing=entity.id))
        self.assertCountEqual(result, [
            obj.id
            for obj in self.luys_in_different_faculty_than_education_group[:1]
        ])

        data = {
            "academic_year_id": self.academic_year.id,
            "faculty_borrowing_acronym": entity.most_recent_acronym
        }

        form = LearningUnitYearForm(data, borrowed_course_search=True)

        form.is_valid()
        results = list(form.get_activity_learning_units())

        self.assertEqual(
            results[0].id,
            self.luys_in_different_faculty_than_education_group[:1][0].id)
Ejemplo n.º 2
0
 def assert_filter_borrowed_luys_returns_empty_qs(self,
                                                  learning_unit_years):
     qs = LearningUnitYear.objects.filter(
         pk__in=[luy.pk for luy in learning_unit_years])
     result = list(
         filter_is_borrowed_learning_unit_year(
             qs, self.academic_year.start_date))
     self.assertFalse(result)
Ejemplo n.º 3
0
 def test_with_learning_unit_when_entity_for_luy_and_education_group_in_different_faculty(
         self):
     qs = LearningUnitYear.objects.filter(pk__in=[
         luy.pk
         for luy in self.luys_in_different_faculty_than_education_group
     ])
     result = list(
         filter_is_borrowed_learning_unit_year(
             qs, self.academic_year.start_date))
     self.assertCountEqual(
         result, self.luys_in_different_faculty_than_education_group)
Ejemplo n.º 4
0
 def test_with_faculty_borrowing_set(self):
     qs = LearningUnitYear.objects.filter(pk__in=[
         luy.pk
         for luy in self.luys_in_different_faculty_than_education_group
     ])
     group = GroupElementYear.objects.get(
         child_leaf=self.luys_in_different_faculty_than_education_group[0])
     entity = OfferYearEntity.objects.get(
         education_group_year=group.parent).entity
     result = list(
         filter_is_borrowed_learning_unit_year(
             qs, self.academic_year.start_date,
             faculty_borrowing=entity.id))
     self.assertCountEqual(
         result, self.luys_in_different_faculty_than_education_group[:1])
Ejemplo n.º 5
0
 def test_empty_queryset(self):
     empty_qs = LearningUnitYear.objects.none()
     result = list(
         filter_is_borrowed_learning_unit_year(
             empty_qs, self.academic_year.start_date))
     self.assertFalse(result)