def test_prepare_xls_content_with_data(self): learning_unit_years = _get_learning_unit_yrs_on_2_different_years( self.previous_academic_year.year, [self.learning_unit_year_1] ) data_dict = prepare_xls_content(learning_unit_years) data = data_dict.get(DATA) self.assertEqual(len(data), 2) learning_unit_yr = self.previous_learning_unit_year self.assertEqual(data[0][0], learning_unit_yr.acronym) self.assertEqual(data[0][1], learning_unit_yr.academic_year.name) self.assertEqual(data[0][2], learning_unit_yr.learning_container_year.get_container_type_display()) self.assertEqual(data[0][3], translate_status(learning_unit_yr.status)) self.assertEqual(data[0][4], learning_unit_yr.get_subtype_display()) self.assertEqual( data[0][5], str(_(learning_unit_yr.get_internship_subtype_display())) if learning_unit_yr.internship_subtype else '' ) self.assertEqual(data[0][6], learning_unit_yr.credits) self.assertEqual(data[0][7], learning_unit_yr.language.name if learning_unit_yr.language else '') self.assertEqual(data[0][8], str(_(learning_unit_yr.get_periodicity_display())) if learning_unit_yr.periodicity else '') self.assertEqual(data[0][9], str(_(learning_unit_yr.quadrimester)) if learning_unit_yr.quadrimester else '') self.assertEqual(data[0][10], str(_(learning_unit_yr.session)) if learning_unit_yr.session else '') self.assertEqual(data[0][11], learning_unit_yr.learning_container_year.common_title) self.assertEqual(data[0][12], learning_unit_yr.specific_title) self.assertEqual(data[0][13], learning_unit_yr.learning_container_year.common_title_english) self.assertEqual(data[0][14], learning_unit_yr.specific_title_english) self.assertEqual(data[0][15], learning_unit_yr.requirement_entity.most_recent_acronym) self.assertEqual(data[0][16], learning_unit_yr.allocation_entity.most_recent_acronym) self.assertEqual(data[0][17], EntityContainerYear.objects.get( learning_container_year=learning_unit_yr.learning_container_year, type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1).entity.most_recent_acronym) self.assertEqual(data[0][18], EntityContainerYear.objects.get( learning_container_year=learning_unit_yr.learning_container_year, type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2).entity.most_recent_acronym) self.assertEqual(data[0][19], _('Yes') if learning_unit_yr.professional_integration else _('No')) if learning_unit_yr.campus: self.assertEqual(data[0][20], learning_unit_yr.campus.organization.name) self.assertEqual(data[0][21], learning_unit_yr.campus) else: self.assertEqual(data[0][20], '') self.assertEqual(data[0][21], '') self.assertEqual(data[0][22], self.partim.subdivision) self.assertEqual(data[0][23], learning_unit_yr.learning_unit.faculty_remark) self.assertEqual(data[0][24], learning_unit_yr.learning_unit.other_remark) self.assertEqual(data[0][25], _('Yes') if learning_unit_yr.learning_container_year.team else _('No')) self.assertEqual(data[0][26], _('Yes') if learning_unit_yr.learning_container_year.is_vacant else _('No')) self.assertEqual(data[0][27], learning_unit_yr.learning_container_year.get_type_declaration_vacant_display()) self.assertEqual(data[0][28], learning_unit_yr.get_attribution_procedure_display())
def test_prepare_xls_content_with_data(self): learning_unit_years = _get_learning_unit_yrs_on_2_different_years( self.previous_academic_year.year, [self.learning_unit_year_1]) data_dict = prepare_xls_content(learning_unit_years) data = data_dict.get(DATA) self.assertEqual(len(data), 2) learning_unit_yr = self.previous_learning_unit_year self.assertEqual(data[0][0], learning_unit_yr.acronym) self.assertEqual(data[0][1], learning_unit_yr.academic_year.name) self.assertEqual( data[0][2], xls_build.translate( learning_unit_yr.learning_container_year.container_type)) self.assertEqual(data[0][3], _translate_status(learning_unit_yr.status)) self.assertEqual(data[0][4], xls_build.translate(learning_unit_yr.subtype)) self.assertEqual( data[0][5], str(_(learning_unit_yr.internship_subtype)) if learning_unit_yr.internship_subtype else '') self.assertEqual(data[0][6], learning_unit_yr.credits) self.assertEqual( data[0][7], learning_unit_yr.language.name if learning_unit_yr.language else '') self.assertEqual( data[0][8], str(_(learning_unit_yr.periodicity)) if learning_unit_yr.periodicity else '') self.assertEqual( data[0][9], str(_(learning_unit_yr.quadrimester)) if learning_unit_yr.quadrimester else '') self.assertEqual( data[0][10], str(_(learning_unit_yr.session)) if learning_unit_yr.session else '') self.assertEqual(data[0][11], learning_unit_yr.learning_container_year.common_title) self.assertEqual(data[0][12], learning_unit_yr.specific_title) self.assertEqual( data[0][13], learning_unit_yr.learning_container_year.common_title_english) self.assertEqual(data[0][14], learning_unit_yr.specific_title_english)
def test_prepare_xls_content_no_data(self): self.assertEqual(prepare_xls_content([]), { 'data': [], CELLS_MODIFIED_NO_BORDER: None, CELLS_TOP_BORDER: None })