def test_should_get_export_list_for_warehouse(self, mock_build_contact):
        contact = {'firstName': 'John', 'lastName': 'Ssenteza', 'phone': '+256 782 123456'}
        mock_build_contact.return_value = contact
        delivery = DeliveryFactory()
        consignee_name = 'the consignee'
        consignee = ConsigneeFactory(name=consignee_name)
        waybill = 5404939
        mama_kit = 'Mama kit'
        material_code = 'Code 30'
        ro_item = ReleaseOrderItemFactory(item=ItemFactory(description=mama_kit, material_code=material_code),
                                          release_order=ReleaseOrderFactory(waybill=waybill))
        delivery_date = '2015-09-06'
        luweero = 'Luweero'
        remark = 'manchester united beat liverpool'
        DeliveryNodeFactory(distribution_plan=delivery, delivery_date=delivery_date,
                            consignee=consignee, item=ro_item, location=luweero, remark=remark)

        header = [
            'Waybill', 'Item Description', 'Material Code', 'Quantity Shipped', 'Shipment Date',
            'Implementing Partner', 'Contact Person', 'Contact Number', 'District', 'Is End User',
            'Is Tracked', 'Remarks']
        row_one = [waybill, mama_kit, material_code, 10, delivery_date, consignee_name,
                   '%s %s' % (contact['firstName'], contact['lastName']),
                   contact['phone'], luweero, 'Yes', 'No', remark]

        expected_data = [header, row_one]

        csv_exporter = DeliveryCSVExporter.create_delivery_exporter_by_type('Warehouse', HOSTNAME)

        self.assertEqual(csv_exporter.assemble_csv_data(), expected_data)
    def test_should_get_export_list_for_direct_delivery(self, mock_build_contact):
        contact = {'firstName': 'John', 'lastName': 'Ssenteza', 'phone': '+256 782 123456'}
        mock_build_contact.return_value = contact
        delivery = DeliveryFactory()
        consignee_name = 'the consignee'
        consignee = ConsigneeFactory(name=consignee_name)
        order_number = 5404939
        mama_kit = 'Mama kit'
        material_code = 'Code 33'
        ro_item = PurchaseOrderItemFactory(item=ItemFactory(description=mama_kit, material_code=material_code),
                                           purchase_order=PurchaseOrderFactory(order_number=order_number))
        delivery_date = '2015-09-06'
        luweero = 'Luweero'
        remark = 'some remark'
        DeliveryNodeFactory(distribution_plan=delivery, delivery_date=delivery_date,
                            consignee=consignee, item=ro_item, location=luweero, remark=remark)

        header = [
            'Purchase Order', 'Item Description', 'Material Code', 'Quantity Shipped', 'Shipment Date',
            'Implementing Partner', 'Contact Person', 'Contact Number', 'District', 'Is End User',
            'Is Tracked', 'Remarks']
        row_one = [order_number, mama_kit, material_code, 10, delivery_date, consignee_name,
                   '%s %s' % (contact['firstName'], contact['lastName']),
                   contact['phone'], luweero, 'Yes', 'No', remark]

        expected_data = [header, row_one]

        csv_exporter = DeliveryCSVExporter.create_delivery_exporter_by_type('Direct', HOSTNAME)

        print 'query_date-->%s' % str(csv_exporter.assemble_csv_data())
        print 'expected_data-->%s' % str(expected_data)
        print 'is_equal-->%s' % str(expected_data == csv_exporter.assemble_csv_data())
        TestCase.maxDiff = None
        self.assertEqual(csv_exporter.assemble_csv_data(), expected_data)
Ejemplo n.º 3
0
    def test_should_get_export_list_for_direct_delivery(self, mock_build_contact):
        self.clean()
        contact = {'firstName': 'John', 'lastName': 'Ssenteza', 'phone': '+256 782 123456'}
        mock_build_contact.return_value = contact
        delivery = DeliveryFactory()
        consignee_name = 'the consignee'
        consignee = ConsigneeFactory(name=consignee_name)
        order_number = 5404939
        mama_kit = 'Mama kit'
        material_code = 'Code 33'
        ro_item = PurchaseOrderItemFactory(item=ItemFactory(description=mama_kit, material_code=material_code),
                                           purchase_order=PurchaseOrderFactory(order_number=order_number))
        delivery_date = '2015-09-06'
        luweero = 'Luweero'
        remark = 'some remark'
        DeliveryNodeFactory(distribution_plan=delivery, delivery_date=delivery_date,
                            consignee=consignee, item=ro_item, location=luweero, remark=remark)

        header = [
            'Purchase Order', 'Item Description', 'Material Code', 'Quantity Shipped', 'Shipment Date',
            'Implementing Partner', 'Contact Person', 'Contact Number', 'District', 'Is End User',
            'Is Tracked', 'Remarks']
        row_one = [order_number, mama_kit, material_code, 10, delivery_date, consignee_name,
                   '%s %s' % (contact['firstName'], contact['lastName']),
                   contact['phone'], luweero, 'Yes', 'No', remark]

        expected_data = [header, row_one]

        csv_exporter = DeliveryCSVExporter.create_delivery_exporter_by_type('Direct', self.HOSTNAME)

        logger.info(expected_data)
        logger.info(csv_exporter.assemble_csv_data())

        self.assertEqual(csv_exporter.assemble_csv_data(), expected_data)
Ejemplo n.º 4
0
def generate_delivery_export_csv(user, delivery_type, host_name):
    csv_export_service = DeliveryCSVExporter.create_delivery_exporter_by_type(
        delivery_type.capitalize(), host_name)
    CSVExportService.generate(csv_export_service.assemble_csv_data(),
                              csv_export_service.export_category,
                              csv_export_service.get_export_csv_file_name())

    CSVExportService.notify(user, *csv_export_service.notification_details())
 def test_should_return_correct_notification_details_for_direct_delivery(self, mock_generate_exported_csv_file_name):
     file_name = 'direct_deliveries_1448892495779.csv'
     mock_generate_exported_csv_file_name.return_value = file_name
     category = 'delivery'
     warehouse_csv_export = DeliveryCSVExporter.create_delivery_exporter_by_type('Direct', HOSTNAME)
     details = ('Direct Delivery Download',
                '%s some content Direct Delivery other content http://ha.ha/static/exports/' + category +
                '/' + file_name)
     self.assertEqual(warehouse_csv_export.notification_details(), details)
    def test_should_return_correct_notification_details_for_direct_delivery(self, mock_generate_exported_csv_file_name):
        file_name = 'direct_deliveries_1448892495779.csv'
        mock_generate_exported_csv_file_name.return_value = file_name
        category = 'delivery'
        direct_csv_export = DeliveryCSVExporter.create_delivery_exporter_by_type('Direct', self.HOSTNAME)
        export_label = direct_csv_export.export_label

        details = (EMAIL_COMMON_SUBJECT, EMAIL_NOTIFICATION_CONTENT.format(export_label,
                                                                           'http://ha.ha/static/exports/' + category +
                                                                           '/' + file_name, CSV_EXPIRED_HOURS))
        self.assertEqual(direct_csv_export.notification_details(), details)
Ejemplo n.º 7
0
    def test_should_return_correct_notification_details_for_direct_delivery(self, mock_generate_exported_csv_file_name):
        file_name = 'direct_deliveries_1448892495779.csv'
        mock_generate_exported_csv_file_name.return_value = file_name
        category = 'delivery'
        direct_csv_export = DeliveryCSVExporter.create_delivery_exporter_by_type('Direct', self.HOSTNAME)
        export_label = direct_csv_export.export_label

        details = (EMAIL_COMMON_SUBJECT, EMAIL_NOTIFICATION_CONTENT.format(export_label,
                                                                           'http://ha.ha/static/exports/' + category +
                                                                           '/' + file_name, CSV_EXPIRED_HOURS))
        self.assertEqual(direct_csv_export.notification_details(), details)
Ejemplo n.º 8
0
def generate_delivery_export_csv(user, delivery_type, host_name):
    csv_export_service = DeliveryCSVExporter.create_delivery_exporter_by_type(delivery_type.capitalize(), host_name)
    CSVExportService.generate(csv_export_service.assemble_csv_data(), csv_export_service.export_category,
                              csv_export_service.get_export_csv_file_name())

    CSVExportService.notify(user, *csv_export_service.notification_details())