예제 #1
0
 def test_is_invalid_case_attach_element_to_itself(self):
     duplicate = AttachEducationGroupYearStrategy(
         parent=self.finality_group,
         child=self.finality_group
     )
     with self.assertRaises(ValidationError):
         self.assertTrue(duplicate.is_valid())
예제 #2
0
 def test_is_valid_case_attach_option_which_are_within_master_120(self):
     """
     In this test, we ensure that we can add an option at specialized finality because
     it is present in root master 2m level
     """
     strategy = AttachEducationGroupYearStrategy(
         parent=self.master_120_specialized,
         child=self.option_in_parent
     )
     self.assertTrue(strategy.is_valid())
예제 #3
0
    def test_is_valid_case_attach_finality_which_have_end_year_lower_than_root(self):
        master_120_didactic = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            academic_year=self.academic_year_2018,
            education_group__end_year=self.academic_year_2019
        )

        strategy = AttachEducationGroupYearStrategy(
            parent=self.finality_group,
            child=master_120_didactic
        )
        self.assertTrue(strategy.is_valid())
예제 #4
0
    def test_is_valid_case_attach_groups_which_contains_options_which_are_within_master_120(self):
        """
        In this test, we ensure that we can add a groups which contains options at specialized finality because
        this options are present in root master 2m level
        """
        subgroup = GroupFactory(education_group_type__name=GroupType.SUB_GROUP.name, academic_year=self.academic_year)
        GroupElementYearFactory(parent=subgroup, child_branch=self.option_in_parent)

        strategy = AttachEducationGroupYearStrategy(
            parent=self.master_120_specialized,
            child=subgroup
        )
        self.assertTrue(strategy.is_valid())
예제 #5
0
    def test_is_not_valid_case_attach_finality_which_have_end_year_undetermined(self):
        master_120_didactic = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            academic_year=self.academic_year_2018,
            education_group__end_year=None
        )

        strategy = AttachEducationGroupYearStrategy(
            parent=self.finality_group,
            child=master_120_didactic
        )
        with self.assertRaises(ValidationError):
            self.assertTrue(strategy.is_valid())
예제 #6
0
    def test_is_not_valid_case_attach_option_which_are_not_within_master_120(self):
        """
        In this test, we ensure that we CANNOT add an option at specialized finality because
        it is not present in root master 2m level
        """
        option_which_are_not_in_2m = MiniTrainingFactory(education_group_type__name=MiniTrainingType.OPTION.name,
                                                         academic_year=self.academic_year)
        strategy = AttachEducationGroupYearStrategy(
            parent=self.master_120_specialized,
            child=option_which_are_not_in_2m
        )

        with self.assertRaises(ValidationError):
            strategy.is_valid()
예제 #7
0
    def test_is_not_valid_case_attach_group_which_contains_option_which_are_not_within_master_120(self):
        """
        In this test, we ensure that we CANNOT add a groups which contains options at specialized finality because
        this options are not present in root master 2m level
        """
        subgroup = GroupFactory(education_group_type__name=GroupType.SUB_GROUP.name, academic_year=self.academic_year)
        option_which_are_not_in_2m = MiniTrainingFactory(education_group_type__name=MiniTrainingType.OPTION.name,
                                                         academic_year=self.academic_year)
        # Error case
        GroupElementYearFactory(parent=subgroup, child_branch=option_which_are_not_in_2m)
        # Good case (present in 2M)
        GroupElementYearFactory(parent=subgroup, child_branch=self.option_in_parent)

        strategy = AttachEducationGroupYearStrategy(
            parent=self.master_120_specialized,
            child=subgroup
        )
        with self.assertRaises(ValidationError):
            strategy.is_valid()
예제 #8
0
    def test_is_not_valid_case_attach_groups_which_contains_finalities_which_have_end_year_greater_than_root(self):
        subgroup = GroupFactory(education_group_type__name=GroupType.SUB_GROUP.name, academic_year=self.academic_year_2018)
        master_120_didactic = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            academic_year=self.academic_year_2018,
            education_group__end_year=self.academic_year_2021
        )
        GroupElementYearFactory(parent=subgroup, child_branch=master_120_didactic)
        master_120_deepening = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MA_120.name,
            academic_year=self.academic_year_2018,
            education_group__end_year=None
        )
        GroupElementYearFactory(parent=subgroup, child_branch=master_120_deepening)

        strategy = AttachEducationGroupYearStrategy(
            parent=self.finality_group,
            child=subgroup
        )
        with self.assertRaises(ValidationError):
            self.assertTrue(strategy.is_valid())
예제 #9
0
    def test_is_case_attach_finality_which_child_branch_duplicate(self):
        master_120_didactic = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            academic_year=self.academic_year_2018,
            education_group__end_year=self.academic_year_2019
        )

        ge = GroupElementYearFactory(parent=self.finality_group, child_branch=master_120_didactic)

        duplicate = AttachEducationGroupYearStrategy(
            parent=self.finality_group,
            child=master_120_didactic
        )
        with self.assertRaises(ValidationError):
            self.assertTrue(duplicate.is_valid())

        update = AttachEducationGroupYearStrategy(
            parent=self.finality_group,
            child=master_120_didactic,
            instance=ge
        )
        self.assertTrue(update.is_valid())