예제 #1
0
 def test_with_filters_case_childs_with_different_academic_years(self):
     child_leaf_other_ac_year = LearningUnitYearFactory(
         academic_year=AcademicYearFactory(
             year=self.current_academic_year.year - 1))
     with self.assertRaises(AttributeError):
         group_element_year._find_related_formations(
             [self.child_leaf, child_leaf_other_ac_year], self.filters)
예제 #2
0
 def test_with_filters_case_direct_parent_id_root_and_matches_filters(self):
     element_year = GroupElementYearFactory(parent=self.root, child_branch=None, child_leaf=self.child_leaf)
     result = group_element_year._find_related_formations([self.child_leaf], self.filters)
     expected_result = {
         self.child_leaf.id: [element_year.parent.id]
     }
     self.assertEqual(result, expected_result)
예제 #3
0
 def test_with_filters_case_objects_are_education_group_instance(self):
     root = EducationGroupYearFactory(
         academic_year=self.current_academic_year, )
     child_branch = EducationGroupYearFactory(
         academic_year=self.current_academic_year, )
     GroupElementYearFactory(parent=root, child_branch=child_branch)
     result = group_element_year._find_related_formations([child_branch],
                                                          self.filters)
     expected_result = {child_branch.id: [root.id]}
     self.assertDictEqual(result, expected_result)
예제 #4
0
 def test_with_filters_case_direct_parent_is_root_and_not_matches_filter(self):
     root = EducationGroupYearFactory(
         academic_year=self.current_academic_year,
         education_group_type=EducationGroupTypeFactory(name='Options choices',
                                                        category=education_group_categories.GROUP)
     )
     GroupElementYearFactory(parent=root, child_branch=None, child_leaf=self.child_leaf)
     expected_result = {
         self.child_leaf.id: []
     }
     result = group_element_year._find_related_formations([self.child_leaf], self.filters)
     self.assertDictEqual(result, expected_result)
예제 #5
0
 def test_with_filters_case_direct_parent_academic_year_is_different(self):
     current_academic_year = create_current_academic_year()
     root_group_type = EducationGroupTypeFactory(name='Bachelor', category=education_group_categories.TRAINING)
     self.root = EducationGroupYearFactory(academic_year=current_academic_year,
                                           education_group_type=root_group_type)
     child_branch = EducationGroupYearFactory(
         academic_year=AcademicYearFactory(year=current_academic_year.year - 1),
         education_group_type=EducationGroupTypeFactory(category=education_group_categories.GROUP)
     )
     GroupElementYearFactory(parent=self.root, child_branch=child_branch)
     GroupElementYearFactory(parent=child_branch, child_branch=None, child_leaf=self.child_leaf)
     result = group_element_year._find_related_formations([self.child_leaf], self.filters)
     self.assertEqual(result[self.child_leaf.id], [self.root.id])
예제 #6
0
 def test_with_filters_case_root_in_2nd_level_and_direct_parent_matches_filter(self):
     root = EducationGroupYearFactory(
         academic_year=self.current_academic_year,
         education_group_type=EducationGroupTypeFactory(name='Master',
                                                        category=education_group_categories.TRAINING)
     )
     child_branch = EducationGroupYearFactory(
         academic_year=self.current_academic_year,
         education_group_type=EducationGroupTypeFactory(name='Didactic Master',
                                                        category=education_group_categories.TRAINING)
     )
     GroupElementYearFactory(parent=root, child_branch=child_branch)
     GroupElementYearFactory(parent=child_branch, child_branch=None, child_leaf=self.child_leaf)
     result = group_element_year._find_related_formations([self.child_leaf], self.filters)
     expected_result = {
         self.child_leaf.id: [child_branch.id]
     }
     self.assertDictEqual(result, expected_result)
     self.assertNotIn(root.id, result)
예제 #7
0
 def test_with_filters_case_multiple_parents_in_2nd_level(self):
     root_2 = EducationGroupYearFactory(
         academic_year=self.current_academic_year,
         education_group_type=EducationGroupTypeFactory(
             name='Master', category=education_group_categories.TRAINING))
     child_branch = EducationGroupYearFactory(
         academic_year=self.current_academic_year,
         education_group_type=EducationGroupTypeFactory(
             category=education_group_categories.GROUP))
     GroupElementYearFactory(parent=self.root, child_branch=child_branch)
     GroupElementYearFactory(parent=root_2, child_branch=child_branch)
     GroupElementYearFactory(parent=child_branch,
                             child_branch=None,
                             child_leaf=self.child_leaf)
     result = group_element_year._find_related_formations([self.child_leaf],
                                                          self.filters)
     expected_result = {self.child_leaf.id: [self.root.id, root_2.id]}
     self.assertEqual(len(result[self.child_leaf.id]), 2)
     self.assertIn(self.root.id, result[self.child_leaf.id])
     self.assertIn(root_2.id, result[self.child_leaf.id])
예제 #8
0
 def test_case_filters_arg_is_none(self):
     result = group_element_year._find_related_formations([self.child_leaf],
                                                          None)
     expected_result = {self.child_leaf.id: []}
     self.assertDictEqual(result, expected_result)
예제 #9
0
 def test_objects_instances_check_is_called(self, mock_check_instance):
     group_element_year._find_related_formations([self.child_leaf],
                                                 self.filters)
     self.assertTrue(mock_check_instance.called)