Esempio n. 1
0
 def test_is_valid_case_detach_option_which_are_not_within_finality_master_120(
         self):
     """
     In this test, we ensure that we can detach an option at 2m because it is not present in any finality 2m
     """
     strategy = DetachEducationGroupYearStrategy(
         link=self.master_120_link_option)
     self.assertTrue(strategy.is_valid())
Esempio n. 2
0
    def test_is_not_valid_case_detach_group_which_contains_option_which_are_reused_in_multiple_2M(
            self):
        """
        In this test, we ensure that we CANNOT detach a group which are reused in two 2m because, one of
        those 2m structure will not be valid anymore
        """
        # Create first 2M
        #   2M
        #   |--OPT1
        #   |--GROUP1
        #      |--OPT1
        #   |--FINALITY_LIST
        #      |--2MS
        #         |--OPT1
        subgroup = GroupFactory(
            acronym='GROUP1',
            education_group_type__name=GroupType.SUB_GROUP.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=self.master_120, child_branch=subgroup)
        group1_link_opt1 = GroupElementYearFactory(
            parent=subgroup, child_branch=self.option_in_parent)
        GroupElementYearFactory(parent=self.master_120_specialized,
                                child_branch=self.option_in_parent)

        # Create another 2M
        #   2M
        #   |--GROUP1
        #      |--OPT1
        #   |--FINALITY_LIST
        #      |--2MD
        #         |--OPT1
        another_master_120 = TrainingFactory(
            education_group_type__name=TrainingType.PGRM_MASTER_120.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=another_master_120,
                                child_branch=subgroup)
        another_finality_group = GroupFactory(
            education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=another_master_120,
                                child_branch=another_finality_group)
        another_master_120_didactic = GroupFactory(
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=another_finality_group,
                                child_branch=another_master_120_didactic)
        GroupElementYearFactory(parent=another_master_120_didactic,
                                child_branch=self.option_in_parent)

        # We try to detach OPT1 from GROUP1 but it is not allowed because another 2M structure won't be valid anymore
        strategy = DetachEducationGroupYearStrategy(link=group1_link_opt1)
        with self.assertRaises(ValidationError):
            strategy.is_valid()
Esempio n. 3
0
    def test_is_valid_case_detach_groups_which_contains_options_which_are_not_within_master_120(
            self):
        """
        In this test, we ensure that we can detach a groups which contains options at 2m because
        this options are present in any finality of this 2m
        """
        subgroup = GroupFactory(
            education_group_type__name=GroupType.SUB_GROUP.name,
            academic_year=self.academic_year)
        master_120_link_subgroup = GroupElementYearFactory(
            parent=self.master_120, child_branch=subgroup)
        GroupElementYearFactory(parent=subgroup,
                                child_branch=self.option_in_parent)

        strategy = DetachEducationGroupYearStrategy(
            link=master_120_link_subgroup)
        self.assertTrue(strategy.is_valid())
Esempio n. 4
0
    def test_is_valid_case_detach_option_which_are_within_finality_master_120_but_present_more_time_in_2m(
            self):
        """
        In this test, we ensure that we can detach an option at 2m level because it is present two time in 2m and
        it is present in one finality of this 2m but, we will detach only one link in 2m
        """
        subgroup = GroupFactory(
            education_group_type__name=GroupType.SUB_GROUP.name,
            academic_year=self.academic_year)
        master_120_link_subgroup = GroupElementYearFactory(
            parent=self.master_120, child_branch=subgroup)
        GroupElementYearFactory(parent=subgroup,
                                child_branch=self.option_in_parent)

        GroupElementYearFactory(parent=self.master_120_specialized,
                                child_branch=self.option_in_parent)
        strategy = DetachEducationGroupYearStrategy(
            link=master_120_link_subgroup)
        self.assertTrue(strategy.is_valid())
Esempio n. 5
0
    def test_is_not_valid_case_detach_option_which_are_within_finality_master_120(
            self):
        """
        In this test, we ensure that we CANNOT detach an option at 2m level because
        it is present in one finality of this 2m
        """
        option = MiniTrainingFactory(
            education_group_type__name=MiniTrainingType.OPTION.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=self.master_120_specialized,
                                child_branch=option)
        master_120_link_option = GroupElementYearFactory(
            parent=self.master_120,
            child_branch=option,
        )

        strategy = DetachEducationGroupYearStrategy(
            link=master_120_link_option)
        self.assertFalse(strategy.is_valid())
Esempio n. 6
0
    def test_warnings_when_prerequisites_in_group_that_is_detached(self):
        strategy = DetachEducationGroupYearStrategy(self.children_level_0[0])
        strategy._check_detach_prerequisite_rules()
        self.assertTrue(strategy.warnings)

        strategy.delete_prerequisites()
        self.assertFalse(Prerequisite.objects.filter(id=self.prerequisite.id))
Esempio n. 7
0
    def test_is_not_valid_case_detach_group_which_contains_option_which_are_within_finality_master_120(
            self):
        """
        In this test, we ensure that we CANNOT detach a group which contains options at 2m level because
        this options are present in one finality of this 2m
        """
        subgroup = GroupFactory(
            education_group_type__name=GroupType.SUB_GROUP.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=self.master_120_specialized,
                                child_branch=subgroup)
        option = MiniTrainingFactory(
            education_group_type__name=MiniTrainingType.OPTION.name,
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=subgroup, child_branch=option)

        master_120_link_option = GroupElementYearFactory(
            parent=self.master_120, child_branch=option)

        strategy = DetachEducationGroupYearStrategy(
            link=master_120_link_option)
        with self.assertRaises(ValidationError):
            strategy.is_valid()
Esempio n. 8
0
 def test_can_detach_if_duplicate_luy(self):
     GroupElementYearChildLeafFactory(
         parent=self.children_level_1[0].child_branch,
         child_leaf=self.lu_children_level_2[0].child_leaf)
     strategy = DetachEducationGroupYearStrategy(self.children_level_1[1])
     self.assertIsNone(strategy._check_detach_prerequisite_rules())
Esempio n. 9
0
 def test_create_error_when_is_prerequisite_in_formation(self):
     strategy = DetachEducationGroupYearStrategy(self.children_level_1[1])
     strategy._check_detach_prerequisite_rules()
     self.assertTrue(strategy.errors)
Esempio n. 10
0
 def test_create_warnings_when_has_prerequisite_in_formation(self):
     strategy = DetachEducationGroupYearStrategy(self.children_level_2[0])
     strategy._check_detach_prerequisite_rules()
     self.assertFalse(strategy.errors)
     self.assertTrue(strategy.warnings)
Esempio n. 11
0
 def test_when_no_prerequisite(self):
     strategy = DetachEducationGroupYearStrategy(self.children_level_1[2])
     self.assertIsNone(strategy._check_detach_prerequisite_rules())
     self.assertFalse(strategy.errors)
     self.assertFalse(strategy.warnings)