def generate_supply_efficiency_report(user, host_name, supply_efficiency_items, supply_efficiency_type): csv_export_service = SupplyEfficiencyReportCSVExporter(host_name, supply_efficiency_type) CSVExportService.generate(csv_export_service.assemble_csv_data(supply_efficiency_items), csv_export_service.export_category, csv_export_service.get_export_csv_file_name()) CSVExportService.notify(user, *csv_export_service.notification_details())
def test_should_assemble_csv_data_for_location_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.location) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["District\nDistrict Name"] + self.fixed_header_cells, ['Wakiso', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_ip_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.ip) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["Implementing Partner\nName"] + self.fixed_header_cells, ['WAKISO DHO', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_po_waybill_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.po_waybill) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["PO / Waybill\nDoc. Number", "PO / Waybill\nType"] + self.fixed_header_cells, [201449, 'PO', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_outcome_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.outcome) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["Outcome\nOutcome Name"] + self.fixed_header_cells, ['YI106 - PCR 2 KEEP CHILDREN LEARNING', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_item_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.item) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["Item\nDescription", "Item\nMaterial Code"] + self.fixed_header_cells, ['Safety box f.used syrgs/ndls 5lt/BOX-25 E', 'SL062334', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_delivery_type_report(self): exporter = SupplyEfficiencyReportCSVExporter('host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.delivery) result_csv = exporter.assemble_csv_data([self.stub_es_service_response]) expected_csv = [ ["Delivery\nDate", "Delivery\nIP", "Delivery\nDistrict"] + self.fixed_header_cells, ['01-Dec-2015', 'WAKISO DHO', 'Wakiso', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0] ] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_location_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.location) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [["District\nDistrict Name"] + self.fixed_header_cells, ['Wakiso', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0]] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_ip_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.ip) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [["Implementing Partner\nName"] + self.fixed_header_cells, ['WAKISO DHO', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0]] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_po_waybill_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.po_waybill) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [["PO / Waybill\nDoc. Number", "PO / Waybill\nType"] + self.fixed_header_cells, [201449, 'PO', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0]] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_outcome_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.outcome) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [["Outcome\nOutcome Name"] + self.fixed_header_cells, [ 'YI106 - PCR 2 KEEP CHILDREN LEARNING', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0 ]] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_item_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.item) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [["Item\nDescription", "Item\nMaterial Code"] + self.fixed_header_cells, [ 'Safety box f.used syrgs/ndls 5lt/BOX-25 E', 'SL062334', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0 ]] self.assertEqual(result_csv, expected_csv)
def test_should_assemble_csv_data_for_delivery_type_report(self): exporter = SupplyEfficiencyReportCSVExporter( 'host_name', SUPPLY_EFFICIENCY_REPORT_TYPES.delivery) result_csv = exporter.assemble_csv_data( [self.stub_es_service_response]) expected_csv = [ ["Delivery\nDate", "Delivery\nIP", "Delivery\nDistrict"] + self.fixed_header_cells, [ '01-Dec-2015', 'WAKISO DHO', 'Wakiso', 2968, 2968, 100, 0, 0, 2968, 0, 0, 0 ] ] self.assertEqual(result_csv, expected_csv)