Esempio n. 1
0
    def setUpTestData(cls):
        cls.parent_type = EducationGroupTypeFactory()
        cls.child_type, cls.other_child_type = EducationGroupTypeFactory.create_batch(2)

        cls.parent_egy = EducationGroupYearFactory(education_group_type=cls.parent_type)
        cls.child_egy = EducationGroupYearFactory(education_group_type=cls.child_type)
        cls.new_link = GroupElementYearFactory.build(child_branch=cls.child_egy)
Esempio n. 2
0
 def test_when_max_reached_after_attaching(self):
     link_to_attach = GroupElementYearFactory.build(
         parent=self.parent_egy,
         child_branch=EducationGroupYearFactory(
             education_group_type=self.education_group_types[0]))
     check = CheckAuthorizedRelationshipAttach(
         self.parent_egy, link_to_attach=link_to_attach)
     self.assertFalse(check.is_valid())
Esempio n. 3
0
 def test_when_children_with_link_reference(self):
     expected_result = [
         self._create_result_record(self.education_group_types[0], 3),
         self._create_result_record(self.education_group_types[1], 4),
         self._create_result_record(self.education_group_types[2], 1 + 2)
     ]
     link = GroupElementYearFactory.build(child_branch=self.child, link_type=LinkTypes.REFERENCE.name)
     self.assertCountEqual(
         list(compute_number_children_by_education_group_type(self.parent_egy, link)),
         expected_result
     )
Esempio n. 4
0
    def test_when_no_children(self):
        parent_without_children = EducationGroupYearFactory()

        expected_result = [
            self._create_result_record(self.education_group_types[0], 1)
        ]
        link = GroupElementYearFactory.build(child_branch=self.child, link_type=None)
        self.assertCountEqual(
            list(compute_number_children_by_education_group_type(parent_without_children, link)),
            expected_result
        )
Esempio n. 5
0
    def test_when_switching_link_type_of_existing_child(self):
        expected_result = [
            self._create_result_record(self.education_group_types[0], 3 + 1),
            self._create_result_record(self.education_group_types[1], 4 - 2)
        ]

        link = GroupElementYearFactory.build(child_branch=self.reference_group_element_year_children.child_branch,
                                             link_type=None)
        self.assertCountEqual(
            list(compute_number_children_by_education_group_type(self.parent_egy, link)),
            expected_result
        )
Esempio n. 6
0
 def test_when_children(self):
     expected_result = [
         self._create_result_record(self.education_group_types[0], 3 + 1),
         self._create_result_record(self.education_group_types[1], 4),
         self._create_result_record(self.education_group_types[2], 1)
     ]
     link = GroupElementYearFactory.build(child_branch=self.child, link_type=None)
     self.assertCountEqual(
         list(compute_number_children_by_education_group_type(self.parent_egy, link)),
         expected_result
     )
     AuthorizedRelationshipFactory(parent_type=self.parent_egy.education_group_type,
                                   child_type=self.child.education_group_type)