Esempio n. 1
0
 def test_when_partial_acronym_existed_in_past(self):
     EducationGroupYearFactory(partial_acronym=self.partial_acronym,
                               academic_year=self.previous_acy)
     e = EducationGroupYearFactory.build(
         partial_acronym=self.partial_acronym,
         academic_year=self.current_acy)
     e.clean_partial_acronym()
Esempio n. 2
0
def _get_valid_post_data(category):
    entity_version = MainEntityVersionFactory()
    education_group_type = EducationGroupTypeFactory(category=category)
    campus = CampusFactory(organization__type=organization_type.MAIN)
    current_academic_year = create_current_academic_year()
    fake_education_group_year = EducationGroupYearFactory.build(
        academic_year=current_academic_year,
        management_entity=entity_version.entity,
        main_teaching_campus=campus,
        education_group_type=education_group_type,
        education_group__start_year=current_academic_year.year,
        constraint_type=CREDITS,
    )
    AuthorizedRelationshipFactory(child_type=fake_education_group_year.education_group_type)
    post_data = {
        'main_teaching_campus': str(fake_education_group_year.main_teaching_campus.id),
        'management_entity': str(entity_version.id),
        'remark_english': str(fake_education_group_year.remark_english),
        'title_english': str(fake_education_group_year.title_english),
        'partial_acronym': str(fake_education_group_year.partial_acronym),
        'end_year': str(fake_education_group_year.education_group.end_year),
        'start_year': str(fake_education_group_year.education_group.start_year),
        'title': str(fake_education_group_year.title),
        'credits': str(fake_education_group_year.credits),
        'academic_year': str(fake_education_group_year.academic_year.id),
        'constraint_type': CREDITS,
        'max_constraint': str(fake_education_group_year.max_constraint),
        'min_constraint': str(fake_education_group_year.min_constraint),
        'remark': str(fake_education_group_year.remark),
        'acronym': str(fake_education_group_year.acronym),
        'active': str(fake_education_group_year.active),
        'schedule_type': str(fake_education_group_year.schedule_type),
    }
    return fake_education_group_year, post_data
Esempio n. 3
0
 def test_raise_validation_warning_when_acronym_existed_in_past_and_raise_warning_set_to_true(
         self):
     EducationGroupYearFactory(acronym=self.acronym,
                               academic_year=self.previous_acy)
     e = EducationGroupYearFactory.build(acronym=self.acronym,
                                         academic_year=self.current_acy)
     with self.assertRaises(ValidationWarning):
         e.clean_acronym(raise_warnings=True)
Esempio n. 4
0
 def test_raise_validation_error_when_acronym_exists_in_present_or_future(
         self):
     for acy in (self.current_acy, self.next_acy):
         with self.subTest(acy=acy):
             EducationGroupYearFactory(acronym=self.acronym,
                                       academic_year=acy)
             e = EducationGroupYearFactory.build(
                 acronym=self.acronym, academic_year=self.current_acy)
             with self.assertRaises(ValidationError):
                 e.clean_acronym()
Esempio n. 5
0
 def test_when_acronym_not_exists(self):
     EducationGroupYearFactory(acronym='CODE1')
     e = EducationGroupYearFactory.build(acronym='CODE2')
     e.clean_acronym()