def test_multiple_warnings_entity_container_year(self): learning_unit_year_to_update = LearningUnitYearFactory( learning_unit=self.learning_unit, learning_container_year=self.learning_container_year, subtype=FULL, academic_year=self.current_academic_year) self.requirement_entity_version.start_date = datetime.date(1990, 9, 15) self.requirement_entity_version.end_date = datetime.date(1990, 9, 15) self.requirement_entity_version.save() self.requirement_entity.refresh_from_db() self.allocation_entity_version.start_date = datetime.date(1990, 9, 15) self.allocation_entity_version.end_date = datetime.date(1990, 9, 15) self.allocation_entity_version.save() self.allocation_entity_version.refresh_from_db() form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL, instance=learning_unit_year_to_update) self.assertTrue(form.is_valid(), form.errors) self.assertEqual(len(form.instance.warnings), 2) self.assertTrue( _("The linked %(entity)s does not exist at the start date of the academic year linked to this" " learning unit") % {'entity': _(REQUIREMENT_ENTITY.lower())} in form.instance.warnings) self.assertTrue( _("The linked %(entity)s does not exist at the start date of the academic year linked to this" " learning unit") % {'entity': _(ALLOCATION_ENTITY.lower())} in form.instance.warnings)
def test_warnings_credit(self): learning_unit_year_to_update = LearningUnitYearFactory( learning_unit=self.learning_unit, learning_container_year=self.learning_container_year, subtype=FULL, academic_year=self.current_academic_year) partim = LearningUnitYearFactory( learning_container_year=self.learning_container_year, subtype=PARTIM, credits=120) self.post_data['credits'] = 60 form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL, instance=learning_unit_year_to_update) self.assertTrue(form.is_valid(), form.errors) self.assertEqual(form.instance.warnings, [ _("The credits value of the partim %(acronym)s is greater or " "equal than the credits value of the parent learning unit.") % { 'acronym': partim.acronym } ])
def test_case_update_post_data_correctly_saved(self): learning_unit_year_to_update = LearningUnitYearFactory( learning_unit=self.learning_unit, learning_container_year=self.learning_container_year, subtype=FULL, academic_year=self.current_academic_year ) form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL, instance=learning_unit_year_to_update) self.assertTrue(form.is_valid(), form.errors) luy = form.save(learning_container_year=self.learning_container_year, learning_unit=self.learning_unit) self.assertEqual(luy, learning_unit_year_to_update)
def test_post_data_correctly_saved_case_creation(self): form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL) self.assertTrue(form.is_valid(), form.errors) luy = form.save(learning_container_year=self.learning_container_year, learning_unit=self.learning_unit) self.assertEqual(luy.acronym, ''.join([self.post_data['acronym_0'], self.post_data['acronym_1']])) self.assertEqual(luy.academic_year.pk, self.post_data['academic_year']) self.assertEqual(luy.specific_title, self.post_data['specific_title']) self.assertEqual(luy.specific_title_english, self.post_data['specific_title_english']) self.assertEqual(luy.credits, self.post_data['credits']) self.assertEqual(luy.session, self.post_data['session']) self.assertEqual(luy.quadrimester, self.post_data['quadrimester']) self.assertEqual(luy.status, self.post_data['status']) self.assertEqual(luy.internship_subtype, self.post_data['internship_subtype']) self.assertEqual(luy.attribution_procedure, self.post_data['attribution_procedure'])
def test_no_warnings_credit(self): """ This test will ensure that no message warning message is displayed when no PARTIM attached to FULL""" learning_unit_year_to_update = LearningUnitYearFactory( learning_unit=self.learning_unit, learning_container_year=self.learning_container_year, subtype=FULL, academic_year=self.current_academic_year ) LearningUnitYear.objects.filter( learning_container_year=learning_unit_year_to_update.learning_container_year, subtype=PARTIM ).delete() self.post_data['credits'] = 60 form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL, instance=learning_unit_year_to_update) self.assertTrue(form.is_valid(), form.errors) self.assertFalse(form.instance.warnings)