def test_check_postponement_conflict_entity_container_year_differences_found( self): # Copy the same container + change academic year another_learning_container_year = _build_copy( self.learning_container_year) another_learning_container_year.academic_year = self.next_academic_year another_learning_container_year.save() # Copy same allocation entity allocation_entity = _build_copy(self.allocation_entity) allocation_entity.learning_container_year = another_learning_container_year allocation_entity.save() # Link to another entity for requirement entityversion = EntityVersionFactory(parent=None, end_date=None, acronym="AREC") requirement_entity = EntityContainerYearFactory( learning_container_year=another_learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY, entity=entityversion.entity) error_list = business_edition._check_postponement_conflict_on_entity_container_year( self.learning_container_year, another_learning_container_year) self.assertIsInstance(error_list, list) self.assertEqual(len(error_list), 2) # invalidate cache del self.requirement_entity.entity.most_recent_acronym generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \ "and year %(next_year)s - %(next_value)s" # Error : Requirement entity diff error_requirement_entity = _(generic_error) % { 'field': _( entity_container_year_link_type.REQUIREMENT_ENTITY.lower()), 'year': self.learning_container_year.academic_year, 'value': self.requirement_entity.entity.most_recent_acronym, 'next_year': another_learning_container_year.academic_year, 'next_value': requirement_entity.entity.most_recent_acronym } self.assertIn(error_requirement_entity, error_list) # Error : Additional requirement entity diff error_requirement_entity = _(generic_error) % { 'field': _(entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1. lower()), 'year': self.learning_container_year.academic_year, 'value': self.add_requirement_entity_1.entity.most_recent_acronym, 'next_year': another_learning_container_year.academic_year, 'next_value': _('no_data') } self.assertIn(error_requirement_entity, error_list)
def test_check_postponement_conflict_entity_container_year_entity_doesnt_exist_anymore( self): # Copy the same container + change academic year another_learning_container_year = _build_copy( self.learning_container_year) another_learning_container_year.academic_year = self.next_academic_year another_learning_container_year.save() # Copy same entity for entity_container_to_copy in [ self.allocation_entity, self.requirement_entity, self.add_requirement_entity_1 ]: entity_copied = _build_copy(entity_container_to_copy) entity_copied.learning_container_year = another_learning_container_year entity_copied.save() # Modify end_date of entity_version self.entity_version.end_date = self.next_academic_year.start_date - timedelta( days=1) self.entity_version.save() error_list = business_edition._check_postponement_conflict_on_entity_container_year( self.learning_container_year, another_learning_container_year) self.assertIsInstance(error_list, list) error_entity_not_exist = _( "The entity '%(acronym)s' doesn't exist anymore in %(year)s" % { 'acronym': self.entity_version.acronym, 'year': self.next_academic_year }) self.assertIn(error_entity_not_exist, error_list)
def test_check_postponement_conflict_entity_container_year_no_difference_found( self): # Copy the same container and entities + change academic year another_learning_container_year = _build_copy( self.learning_container_year) another_learning_container_year.academic_year = self.next_academic_year another_learning_container_year.save() # No diff found error_list = business_edition._check_postponement_conflict_on_entity_container_year( self.learning_container_year, another_learning_container_year) self.assertIsInstance(error_list, list) self.assertFalse(error_list)
def test_check_postponement_conflict_entity_container_year_no_difference_found(self): # Copy the same container + change academic year another_learning_container_year = _build_copy(self.learning_container_year) another_learning_container_year.academic_year = self.next_academic_year another_learning_container_year.save() # Copy same entity for entity_container_to_copy in [self.allocation_entity, self.requirement_entity, self.add_requirement_entity_1]: entity_copied = _build_copy(entity_container_to_copy) entity_copied.learning_container_year = another_learning_container_year entity_copied.save() # No diff found error_list = business_edition._check_postponement_conflict_on_entity_container_year( self.learning_container_year,another_learning_container_year ) self.assertIsInstance(error_list, list) self.assertFalse(error_list)