def setUpTestData(cls): academic_year = AcademicYearFactory() minor_list_type = EducationGroupTypeFactory( category=education_group_categories.GROUP, name=education_group_types.GroupType.MINOR_LIST_CHOICE.name, ) common_type = EducationGroupTypeFactory( category=education_group_categories.GROUP, name=education_group_types.GroupType.COMMON_CORE, ) cls.base_1 = GroupFactory(education_group_type=common_type, acronym="BASE", academic_year=academic_year) child_1 = GroupFactory(education_group_type=common_type, acronym="CHILD", academic_year=academic_year) minor_list_choice = GroupFactory(education_group_type=minor_list_type, acronym="MINOR LIST", academic_year=academic_year) minor_content_1 = MiniTrainingFactory( education_group_type=minor_list_type, academic_year=academic_year) minor_content_2 = MiniTrainingFactory( education_group_type=minor_list_type, academic_year=academic_year) cls.groupe_element_yr_1 = GroupElementYearFactory( parent=cls.base_1, child_branch=minor_list_choice) cls.groupe_element_yr_2 = GroupElementYearFactory(parent=cls.base_1, child_branch=child_1) cls.groupe_element_yr_3 = GroupElementYearFactory( parent=minor_list_choice, child_branch=minor_content_1) cls.groupe_element_yr_4 = GroupElementYearFactory( parent=minor_list_choice, child_branch=minor_content_2)
def test_when_multiple_elements_selected(self): other_egy = GroupFactory(academic_year__current=True) other_other_egy = GroupFactory(academic_year__current=True) AuthorizedRelationshipFactory( parent_type=self.egy.education_group_type, child_type=other_egy.education_group_type, min_count_authorized=0, max_count_authorized=None ) AuthorizedRelationshipFactory( parent_type=self.egy.education_group_type, child_type=other_other_egy.education_group_type, min_count_authorized=0, max_count_authorized=None ) querydict = QueryDict(mutable=True) querydict.update({"content_type": EDUCATION_GROUP_YEAR}) querydict.setlist("id", [other_egy.id, other_other_egy.id]) url_parameters = querydict.urlencode() response = self.client.post(self.url + "?" + url_parameters, data={ 'form-TOTAL_FORMS': '2', 'form-INITIAL_FORMS': '0', 'form-MAX_NUM_FORMS': '2', }) self.assertEqual(response.status_code, HttpResponseRedirect.status_code) self.assertTrue( GroupElementYear.objects.get(parent=self.egy, child_branch=other_egy) ) self.assertTrue( GroupElementYear.objects.get(parent=self.egy, child_branch=other_other_egy) )
def test_have_contents_case_contents_because_structure_have_child_which_are_not_mandatory( self): """ In this test, we ensure that at least one children are not mandatory groups so they must not be considered as empty """ education_group_year = TrainingFactory( academic_year=self.academic_year) child_mandatory = GroupFactory(academic_year=self.academic_year) AuthorizedRelationshipFactory( parent_type=education_group_year.education_group_type, child_type=child_mandatory.education_group_type, min_count_authorized=1) GroupElementYearFactory(parent=education_group_year, child_branch=child_mandatory) child_no_mandatory = GroupFactory(academic_year=self.academic_year) AuthorizedRelationshipFactory( parent_type=education_group_year.education_group_type, child_type=child_mandatory.education_group_type, min_count_authorized=0) GroupElementYearFactory(parent=education_group_year, child_branch=child_no_mandatory) self.assertTrue( delete._have_contents_which_are_not_mandatory( education_group_year))
def test_if_structure_is_postponed(self): parent = EducationGroupYearFactory( education_group=self.education_group, academic_year=self.academic_years[-2], ) mandatory_child = GroupFactory(academic_year=self.academic_years[-2], ) not_mandatory_child = GroupFactory( academic_year=self.academic_years[-2], ) GroupElementYearFactory(parent=parent, child_branch=mandatory_child) GroupElementYearFactory(parent=parent, child_branch=not_mandatory_child) AuthorizedRelationshipFactory( parent_type=parent.education_group_type, child_type=mandatory_child.education_group_type, min_count_authorized=1) AuthorizedRelationshipFactory( parent_type=parent.education_group_type, child_type=not_mandatory_child.education_group_type, min_count_authorized=0) self.assertEqual(EducationGroupYear.objects.count(), 3) result, errors = EducationGroupAutomaticPostponementToN6().postpone() self.assertEqual(len(result), 1) self.assertFalse(errors) self.assertEqual(result[0].education_group, self.education_group) self.assertEqual(result[0].groupelementyear_set.count(), 1)
def setUp(self): # Create 2m pgrm structure as # 2M # |--FINALITY_LIST # |--2MS # |--2MD self.master_120 = TrainingFactory( academic_year=self.academic_year_2018, education_group_type__name=TrainingType.PGRM_MASTER_120.name, education_group__end_year=None ) self.finality_group = GroupFactory( academic_year=self.academic_year_2018, education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name, education_group__end_year=None ) GroupElementYearFactory(parent=self.master_120, child_branch=self.finality_group) self.master_120_specialized = GroupFactory( academic_year=self.academic_year_2018, education_group_type__name=TrainingType.MASTER_MS_120.name, education_group__end_year=None ) GroupElementYearFactory(parent=self.finality_group, child_branch=self.master_120_specialized) self.master_120_didactic = GroupFactory( academic_year=self.academic_year_2018, education_group_type__name=TrainingType.MASTER_MD_120.name, education_group__end_year=self.academic_year_2019 ) GroupElementYearFactory(parent=self.finality_group, child_branch=self.master_120_didactic)
def setUpTestData(cls): """ |--Common Core |-- Learning unit year |-- Sub group """ cls.academic_year = AcademicYearFactory(year=2018) cls.common_core = GroupFactory( education_group_type__name=GroupType.COMMON_CORE.name, academic_year=cls.academic_year) cls.learning_unit_year = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.common_core, child_branch=None, child_leaf=cls.learning_unit_year) cls.sub_group = GroupFactory( education_group_type__name=GroupType.SUB_GROUP.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.common_core, child_branch=cls.sub_group, child_leaf=None) cls.person = PersonFactory() url_kwargs = { 'partial_acronym': cls.common_core.partial_acronym, 'year': cls.common_core.academic_year.year } cls.url = reverse('education_group_api_v1:' + GroupTreeView.name, kwargs=url_kwargs)
def setUpTestData(cls): cls.academic_year = AcademicYearFactory() cls.master_120 = TrainingFactory( education_group_type__name=TrainingType.PGRM_MASTER_120.name, academic_year=cls.academic_year) cls.option_in_parent = MiniTrainingFactory( acronym="OPT1", education_group_type__name=MiniTrainingType.OPTION.name, academic_year=cls.academic_year) cls.master_120_link_option = GroupElementYearFactory( parent=cls.master_120, child_branch=cls.option_in_parent) # Create finality structure cls.finality_group = GroupFactory( education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.master_120, child_branch=cls.finality_group) cls.master_120_specialized = GroupFactory( education_group_type__name=TrainingType.MASTER_MS_120.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.finality_group, child_branch=cls.master_120_specialized)
def test_have_contents_case_have_contents_because_mandatory_structure_is_present_multiple_times( self): """ In this test, we ensure that we have two elements of one type which are mandatory in the basic structure. ==> We must consider as it have contents """ education_group_year = TrainingFactory( academic_year=self.academic_year) subgroup_1 = GroupFactory( academic_year=self.academic_year, education_group_type__name=GroupType.SUB_GROUP.name) GroupElementYearFactory(parent=education_group_year, child_branch=subgroup_1) subgroup_2 = GroupFactory( academic_year=self.academic_year, education_group_type=subgroup_1.education_group_type, ) GroupElementYearFactory(parent=education_group_year, child_branch=subgroup_2) AuthorizedRelationshipFactory( parent_type=education_group_year.education_group_type, child_type=subgroup_1.education_group_type, min_count_authorized=1, ) self.assertTrue( delete._have_contents_which_are_not_mandatory( education_group_year))
def test_no_validation_error_when_group_reuse_acronym_of_another_group( self): for acy in (self.current_acy, self.next_acy): with self.subTest(acy=acy): GroupFactory(acronym=self.acronym, academic_year=acy) e = GroupFactory.build(acronym=self.acronym, academic_year=self.current_acy) e.clean_acronym()
def setUp(self): self.current_academic_year = create_current_academic_year() self.education_group_year = GroupFactory() EntityVersionFactory( entity=self.education_group_year.management_entity, start_date=self.education_group_year.academic_year.start_date) EntityVersionFactory( entity=self.education_group_year.administration_entity, start_date=self.education_group_year.academic_year.start_date) AuthorizedRelationshipFactory( parent_type=self.education_group_year.education_group_type, child_type=self.education_group_year.education_group_type) self.url = reverse( update_education_group, args=[self.education_group_year.pk, self.education_group_year.pk]) self.person = PersonFactory() self.client.force_login(self.person.user) permission = Permission.objects.get(codename='change_educationgroup') self.person.user.user_permissions.add(permission) self.perm_patcher = mock.patch( "base.business.education_groups.perms.is_eligible_to_change_education_group", return_value=True) self.mocked_perm = self.perm_patcher.start() self.an_training_education_group_type = EducationGroupTypeFactory( category=education_group_categories.TRAINING) self.training_education_group_year = TrainingFactory( academic_year=self.current_academic_year, education_group_type=self.an_training_education_group_type) AuthorizedRelationshipFactory( parent_type=self.an_training_education_group_type, child_type=self.an_training_education_group_type, ) EntityVersionFactory( entity=self.training_education_group_year.management_entity, start_date=self.education_group_year.academic_year.start_date) EntityVersionFactory( entity=self.training_education_group_year.administration_entity, start_date=self.education_group_year.academic_year.start_date) self.training_url = reverse(update_education_group, args=[ self.training_education_group_year.pk, self.training_education_group_year.pk ]) self.domains = [DomainFactory() for x in range(10)]
def setUpTestData(cls): """ DROI2M |--Common Core |-- Learning unit year |--Finality list choice |-- DROI2MS/IU |--Common core """ cls.academic_year = AcademicYearFactory(year=2018) cls.training = TrainingFactory( acronym='DROI2M', partial_acronym='LBROI200M', academic_year=cls.academic_year, education_group_type__name=TrainingType.PGRM_MASTER_120.name) cls.common_core = GroupFactory( education_group_type__name=GroupType.COMMON_CORE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.training, child_branch=cls.common_core, child_leaf=None) cls.learning_unit_year = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.common_core, child_branch=None, child_leaf=cls.learning_unit_year) cls.finality_list_choice = GroupFactory( education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.training, child_branch=cls.finality_list_choice, child_leaf=None) cls.training_ms = TrainingFactory( acronym='DROI2MS/IU', partial_acronym='LIURE200S', academic_year=cls.academic_year, education_group_type__name=TrainingType.MASTER_MS_120) GroupElementYearFactory(parent=cls.finality_list_choice, child_branch=cls.training_ms, child_leaf=None) cls.common_core_ms = GroupFactory( education_group_type__name=GroupType.COMMON_CORE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.training_ms, child_branch=cls.common_core_ms, child_leaf=None) cls.person = PersonFactory() url_kwargs = { 'acronym': cls.training.acronym, 'year': cls.training.academic_year.year } cls.url = reverse('education_group_api_v1:' + TrainingTreeView.name, kwargs=url_kwargs)
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()
def test_parent_by_training(self): parent_by_training = self.education_group_year_3.is_training() self.assertTrue(parent_by_training) parent_by_training = self.education_group_year_2.parent_by_training() self.assertIsNone(parent_by_training) with self.assertRaises(MaximumOneParentAllowedException): self.education_group_year_1.parent_by_training() group = GroupFactory(academic_year=self.academic_year) GroupElementYearFactory(child_branch=group, parent=self.education_group_year_2) self.assertIsNone(group.parent_by_training())
def test_raise_permission_denied_when_minor_or_major_list_choice_and_person_is_faculty_manager(self): OpenAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION, academic_year=self.previous_acy) egys = [ GroupFactory(education_group_type__name=GroupType.MINOR_LIST_CHOICE.name, academic_year=self.current_acy), GroupFactory(education_group_type__name=GroupType.MAJOR_LIST_CHOICE.name, academic_year=self.current_acy) ] person_entity = PersonEntityFactory(entity=self.group_element_year.parent.management_entity, person=FacultyManagerFactory()) for egy in egys: with self.subTest(type=egy.education_group_type): with self.assertRaises(PermissionDenied): group_element_year = GroupElementYearFactory(parent=self.group_element_year.parent, child_branch=egy) can_update_group_element_year(person_entity.person.user, group_element_year)
def setUpTestData(cls): """ |LBIOL212O - Cours au choix |--Common Core |-- Learning unit year """ cls.academic_year = AcademicYearFactory(year=2018) cls.mini_training = MiniTrainingFactory( acronym="CCHOIXM60", partial_acronym='LBIOL212O', academic_year=cls.academic_year) cls.common_core = GroupFactory( education_group_type__name=GroupType.COMMON_CORE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.mini_training, child_branch=cls.common_core, child_leaf=None) cls.learning_unit_year = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.common_core, child_branch=None, child_leaf=cls.learning_unit_year) cls.person = PersonFactory() url_kwargs = { 'partial_acronym': cls.mini_training.partial_acronym, 'year': cls.mini_training.academic_year.year } cls.url = reverse('education_group_api_v1:' + MiniTrainingTreeView.name, kwargs=url_kwargs)
def test_delete_case_remove_mandatory_structure_case_reused_item_which_are_mandatory( self): """ In this test, we ensure that the mandatory elem is not removed if it is reused in another structure """ education_group_year = TrainingFactory( academic_year=self.academic_year) child_mandatory = GroupFactory( academic_year=self.academic_year, education_group_type__name=GroupType.COMMON_CORE.name) AuthorizedRelationshipFactory( parent_type=education_group_year.education_group_type, child_type=child_mandatory.education_group_type, min_count_authorized=1, ) link_parent_child = GroupElementYearFactory( parent=education_group_year, child_branch=child_mandatory) # Create another training another_training = TrainingFactory(academic_year=self.academic_year) GroupElementYearFactory(parent=another_training, child_branch=child_mandatory) delete.start(education_group_year) with self.assertRaises(EducationGroupYear.DoesNotExist): EducationGroupYear.objects.get(pk=education_group_year.pk) with self.assertRaises(GroupElementYear.DoesNotExist): GroupElementYear.objects.get(pk=link_parent_child.pk) self.assertEqual(child_mandatory, EducationGroupYear.objects.get(pk=child_mandatory.pk))
def test_context_data_when_education_group_year_root_is_not_a_training( self): education_group_year_group = GroupFactory( academic_year=self.academic_year) GroupElementYearFactory(parent=self.education_group_year_parents[0], child_branch=education_group_year_group) GroupElementYearFactory(parent=education_group_year_group, child_leaf=self.learning_unit_year_child, child_branch=None) url = reverse("learning_unit_prerequisite", args=[ education_group_year_group.id, self.learning_unit_year_child.id ]) response = self.client.get(url) self.assertCountEqual(response.context_data["formations"], self.education_group_year_parents) actual_prerequisites = next( filter( lambda egy: egy.id == self.education_group_year_parents[0].id, response.context_data["formations"])).prerequisites self.assertEqual(actual_prerequisites, [self.prerequisite]) actual_prerequisites = next( filter( lambda egy: egy.id == self.education_group_year_parents[1].id, response.context_data["formations"])).prerequisites self.assertEqual(actual_prerequisites, [])
def setUpTestData(cls): cls.academic_year_2017 = AcademicYearFactory(year=2017) cls.academic_year_2018 = AcademicYearFactory(year=2018) cls.academic_year_2019 = AcademicYearFactory(year=2019) cls.academic_year_2020 = AcademicYearFactory(year=2020) cls.academic_year_2021 = AcademicYearFactory(year=2021) cls.master_120 = TrainingFactory( education_group_type__name=TrainingType.PGRM_MASTER_120.name, academic_year=cls.academic_year_2018, education_group__end_year=cls.academic_year_2020 ) cls.finality_group = GroupFactory( education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name, academic_year=cls.academic_year_2018, education_group__end_year=cls.academic_year_2020 ) GroupElementYearFactory(parent=cls.master_120, child_branch=cls.finality_group) cls.master_120_specialized = TrainingFactory( education_group_type__name=TrainingType.MASTER_MS_120.name, academic_year=cls.academic_year_2018, education_group__end_year=cls.academic_year_2020 ) GroupElementYearFactory(parent=cls.finality_group, child_branch=cls.master_120_specialized)
def test_group_template_used(self): group = GroupFactory() url = reverse("education_group_read", args=[group.pk, group.pk]) expected_template = "education_group/identification_group_details.html" response = self.client.get(url) self.assertTemplateUsed(response, expected_template)
def test_have_contents_case_no_contents_which_because_mandatory_structure( self): """ In this test, we ensure that all of his children are mandatory groups and they are empty. It must be consider as empty """ education_group_year = TrainingFactory( academic_year=self.academic_year) for education_group_type in [ GroupType.COMMON_CORE.name, GroupType.FINALITY_120_LIST_CHOICE.name ]: child = GroupFactory( academic_year=self.academic_year, education_group_type__name=education_group_type) AuthorizedRelationshipFactory( parent_type=education_group_year.education_group_type, child_type=child.education_group_type, min_count_authorized=1, ) GroupElementYearFactory(parent=education_group_year, child_branch=child) self.assertFalse( delete._have_contents_which_are_not_mandatory( education_group_year))
def setUpTestData(cls): """ BIR1BA |--Common Core |-- Learning Unit Year """ cls.academic_year = AcademicYearFactory(year=2018) cls.training = TrainingFactory(acronym='BIR1BA', partial_acronym='LBIR1000I', academic_year=cls.academic_year) cls.common_core = GroupFactory( education_group_type__name=GroupType.COMMON_CORE.name, academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.training, child_branch=cls.common_core, child_leaf=None) cls.learning_unit_year = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year) GroupElementYearFactory(parent=cls.common_core, child_branch=None, child_leaf=cls.learning_unit_year) cls.person = PersonFactory() url_kwargs = { 'acronym': cls.learning_unit_year.acronym, 'year': cls.learning_unit_year.academic_year.year } cls.url = reverse('learning_unit_api_v1:' + EducationGroupRootsList.name, kwargs=url_kwargs)
def setUpTestData(cls): cls.root_egy = EducationGroupYearFactory() cls.egy_to_find = GroupFactory(acronym='RAV', title='The Ravenlord', partial_acronym="RV") cls.user = SuperUserFactory() cls.url = reverse('quick_search_education_group', args=[cls.root_egy.id, cls.root_egy.id])
def test_create_with_parent(self, mock_find_authorized_types): parent = GroupFactory() form = GroupForm(data=self.post_data, parent=parent, user=self.user, education_group_type=self.egt) self.assertTrue(form.is_valid(), form.errors) education_group_year = form.save() self.assertTrue(GroupElementYear.objects.get(child_branch=education_group_year, parent=parent))
def setUpTestData(cls): cls.academic_year = AcademicYearFactory() cls.root = TrainingFactory( acronym='DROI2M', education_group_type__name=education_group_types.TrainingType. PGRM_MASTER_120, academic_year=cls.academic_year) finality_list = GroupFactory( acronym='LIST FINALITIES', education_group_type__name=education_group_types.GroupType. FINALITY_120_LIST_CHOICE, academic_year=cls.academic_year) formation_master_md = TrainingFactory( acronym='DROI2MD', education_group_type__name=education_group_types.TrainingType. MASTER_MD_120, academic_year=cls.academic_year) common_core = GroupFactory( acronym='TC DROI2MD', education_group_type__name=education_group_types.GroupType. COMMON_CORE, academic_year=cls.academic_year) cls.link_1 = GroupElementYearFactory(parent=cls.root, child_branch=finality_list, child_leaf=None) cls.link_1_bis = GroupElementYearFactory( parent=cls.root, child_branch=EducationGroupYearFactory( academic_year=cls.academic_year), child_leaf=None) cls.link_2 = GroupElementYearFactory(parent=finality_list, child_branch=formation_master_md, child_leaf=None) cls.link_3 = GroupElementYearFactory(parent=formation_master_md, child_branch=common_core, child_leaf=None) cls.link_4 = GroupElementYearFactory( parent=common_core, child_leaf=LearningUnitYearFactory(), child_branch=None)
def test_education_group_year_is_not_training_type(self): type_not_allowed = (MiniTrainingFactory( academic_year=self.academic_year), GroupFactory(academic_year=self.academic_year)) for education_group_year in type_not_allowed: with self.subTest(education_group_year=education_group_year): perm = CertificateAimsPerms( user=SuperUserFactory(), education_group_year=education_group_year) self.assertFalse(perm.is_eligible())
def test_when_link_minor_to_minor_list_choice(self): minor_list_choice = GroupFactory( education_group_type__name=GroupType.MINOR_LIST_CHOICE.name) minor = MiniTrainingFactory(education_group_type__name=random.choice( MiniTrainingType.minors())) link = GroupElementYear(parent=minor_list_choice, child_branch=minor, link_type=None) link._clean_link_type() self.assertEqual(link.link_type, LinkTypes.REFERENCE.name)
def test_when_link_deepening_to_minor_list_choice(self): minor_list_choice = GroupFactory( education_group_type__name=GroupType.MINOR_LIST_CHOICE.name) deepening = MiniTrainingFactory( education_group_type__name=MiniTrainingType.DEEPENING.name) link = GroupElementYear(parent=minor_list_choice, child_branch=deepening, link_type=None) link._clean_link_type() self.assertEqual(link.link_type, LinkTypes.REFERENCE.name)
def test_when_link_major_to_major_list_choice(self): major_list_choice = GroupFactory( education_group_type__name=GroupType.MAJOR_LIST_CHOICE.name) major = MiniTrainingFactory( education_group_type__name=MiniTrainingType.FSA_SPECIALITY.name) link = GroupElementYear(parent=major_list_choice, child_branch=major, link_type=None) link._clean_link_type() self.assertEqual(link.link_type, LinkTypes.REFERENCE.name)
def test_permission_denied_when_context_not_a_formation(self): group_parent = GroupFactory(academic_year=self.academic_year) PersonEntityFactory(person=self.person, entity=group_parent.management_entity) url = reverse("learning_unit_prerequisite_update", args=[group_parent.id, self.learning_unit_year_child.id]) response = self.client.get(url) self.assertEqual(response.status_code, HttpResponseForbidden.status_code) self.assertIn( "{} - {}".format(group_parent.partial_acronym, group_parent.acronym), str(response.context['exception']))
def test_template_used_when_root_is_not_a_training(self): education_group_year_group = GroupFactory(academic_year=self.academic_year) GroupElementYearFactory(parent=self.education_group_year_parents[0], child_branch=education_group_year_group) GroupElementYearFactory(parent=education_group_year_group, child_leaf=self.learning_unit_year_child, child_branch=None) url = reverse("learning_unit_prerequisite", args=[education_group_year_group.id, self.learning_unit_year_child.id]) response = self.client.get(url) self.assertTemplateUsed(response, "education_group/learning_unit/tab_prerequisite_group.html")