def test_should_return_parent_consignee_name_as_sender_for_node_when_parent(self):
        parent_consignee = ConsigneeFactory(name="Arsenal Fan Club")
        parent_node = DeliveryNodeFactory(consignee=parent_consignee)
        child_node = DeliveryNodeFactory(parents=[(parent_node, 5)])
        message = DeliveryRunMessage(child_node)

        self.assertEqual(message.sender_name(), "Arsenal Fan Club")
    def test_should_return_description_of_the_item_when_runnable_is_delivery_node(self):
        item = ItemFactory(description='go gunners')
        order_item = PurchaseOrderItemFactory(item=item)
        node = DeliveryNodeFactory(item=order_item)

        message = DeliveryRunMessage(node)

        self.assertEqual(message.description(), 'go gunners')
    def test_should_return_parent_consignee_name_as_sender_for_node_when_parent(
            self):
        parent_consignee = ConsigneeFactory(name="Arsenal Fan Club")
        parent_node = DeliveryNodeFactory(consignee=parent_consignee)
        child_node = DeliveryNodeFactory(parents=[(parent_node, 5)])
        message = DeliveryRunMessage(child_node)

        self.assertEqual(message.sender_name(), "Arsenal Fan Club")
Exemple #4
0
def _schedule_run(runnable_id):
    logger.info("runnable_id=%s" % runnable_id)
    runnable = Runnable.objects.get(id=runnable_id)
    message = DeliveryRunMessage(runnable)
    rapid_pro_service.create_run(runnable.build_contact(), runnable.flow(),
                                 message.description(), message.sender_name())
    ready_to_start_run = runnable.ready_to_start_run()
    if ready_to_start_run:
        ready_to_start_run.update_status(Run.STATUS.scheduled)
Exemple #5
0
def _schedule_run(runnable_id):
    logger.info("runnable_id=%s" % runnable_id)
    runnable = Runnable.objects.get(id=runnable_id)
    message = DeliveryRunMessage(runnable)
    rapid_pro_service.create_run(runnable.build_contact(), runnable.flow(),
                                 message.description(), message.sender_name())
    ready_to_start_run = runnable.ready_to_start_run()
    if ready_to_start_run:
        ready_to_start_run.update_status(Run.STATUS.scheduled)
    def test_should_return_description_of_the_item_when_runnable_is_delivery_node(
            self):
        item = ItemFactory(description='go gunners')
        order_item = PurchaseOrderItemFactory(item=item)
        node = DeliveryNodeFactory(item=order_item)

        message = DeliveryRunMessage(node)

        self.assertEqual(message.description(), 'go gunners')
    def test_should_return_description_of_release_order_item_with_waybill_and_order_number(self):
        release_order = ReleaseOrderFactory(waybill=444555888)
        item = ReleaseOrderItemFactory(release_order=release_order)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=item)

        message = DeliveryRunMessage(delivery)

        self.assertRegexpMatches(message.description(), r'waybill(?i)')
        self.assertRegexpMatches(message.description(), r'444555888')
    def test_should_return_description_of_purchase_order_item_with_purchase_order_and_order_number(self):
        purchase_order = PurchaseOrderFactory(order_number=222333444)
        item = PurchaseOrderItemFactory(purchase_order=purchase_order)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=item)

        message = DeliveryRunMessage(delivery)

        self.assertRegexpMatches(message.description(), r'purchase order(?i)')
        self.assertRegexpMatches(message.description(), r'222333444')
Exemple #9
0
def _schedule_run(runnable_id):
    runnable = Runnable.objects.get(id=runnable_id)
    flow = runnable.flow()
    message = DeliveryRunMessage(runnable)
    start_delivery_run(
        sender=message.sender_name(),
        item_description=message.description(),
        contact_person=runnable.build_contact(),
        flow=flow.rapid_pro_id
    )
    def test_should_return_description_of_purchase_order_item_with_purchase_order_and_order_number(
            self):
        purchase_order = PurchaseOrderFactory(order_number=222333444)
        item = PurchaseOrderItemFactory(purchase_order=purchase_order)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=item)

        message = DeliveryRunMessage(delivery)

        self.assertRegexpMatches(message.description(), r'purchase order(?i)')
        self.assertRegexpMatches(message.description(), r'222333444')
    def test_should_return_description_of_release_order_item_with_waybill_and_order_number(
            self):
        release_order = ReleaseOrderFactory(waybill=444555888)
        item = ReleaseOrderItemFactory(release_order=release_order)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=item)

        message = DeliveryRunMessage(delivery)

        self.assertRegexpMatches(message.description(), r'waybill(?i)')
        self.assertRegexpMatches(message.description(), r'444555888')
Exemple #12
0
def _schedule_run(runnable_id):
    runnable = Runnable.objects.get(id=runnable_id)
    message = DeliveryRunMessage(runnable)
    rapid_pro_service.create_run(runnable.build_contact(), runnable.flow(),
                                 message.description(), message.sender_name())
    def test_should_return_unicef_as_sender_for_delivery(self):
        delivery = DeliveryNodeFactory()
        message = DeliveryRunMessage(delivery)

        self.assertEqual(message.sender_name(),
                         DeliveryRunMessage.UNICEF_SENDER)
    def test_should_return_unicef_as_sender_for_node_when_no_parent(self):
        node = DeliveryNodeFactory()
        message = DeliveryRunMessage(node)

        self.assertEqual(message.sender_name(),
                         DeliveryRunMessage.UNICEF_SENDER)
    def test_should_return_unicef_as_sender_for_node_when_no_parent(self):
        node = DeliveryNodeFactory()
        message = DeliveryRunMessage(node)

        self.assertEqual(message.sender_name(), DeliveryRunMessage.UNICEF_SENDER)
    def test_should_return_unicef_as_sender_for_delivery(self):
        delivery = DeliveryNodeFactory()
        message = DeliveryRunMessage(delivery)

        self.assertEqual(message.sender_name(), DeliveryRunMessage.UNICEF_SENDER)
Exemple #17
0
def _schedule_run(runnable_id):
    runnable = Runnable.objects.get(id=runnable_id)
    message = DeliveryRunMessage(runnable)
    rapid_pro_service.create_run(runnable.build_contact(), runnable.flow(),
                                 message.description(), message.sender_name())