当前位置: 首页>>代码示例>>Python>>正文


Python delivery_factory.DeliveryFactory类代码示例

本文整理汇总了Python中eums.test.factories.delivery_factory.DeliveryFactory的典型用法代码示例。如果您正苦于以下问题:Python DeliveryFactory类的具体用法?Python DeliveryFactory怎么用?Python DeliveryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DeliveryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_should_create_alert

    def test_should_create_alert(self, mock_contact):
        purchase_order = PurchaseOrderFactory(order_number=5678)
        purchase_order_item = PurchaseOrderItemFactory(purchase_order=purchase_order)
        consignee = ConsigneeFactory(name="Liverpool FC")

        contact_person_id = 'some_id'
        contact = {u'_id': contact_person_id,
                   u'firstName': u'Chris',
                   u'lastName': u'George',
                   u'phone': u'+256781111111'}
        mock_contact.return_value = contact

        delivery = DeliveryFactory(consignee=consignee, contact_person_id=contact_person_id)
        DeliveryNodeFactory(item=purchase_order_item, distribution_plan=delivery)

        delivery.create_alert(Alert.ISSUE_TYPES.not_received)

        alerts = Alert.objects.filter(consignee_name="Liverpool FC", order_number=5678)
        self.assertEqual(alerts.count(), 1)
        alert = alerts.first()
        self.assertEqual(alert.order_type, PurchaseOrderItem.PURCHASE_ORDER)
        self.assertEqual(alert.order_number, 5678)
        self.assertEqual(alert.consignee_name, "Liverpool FC")
        self.assertEqual(alert.contact['contact_name'], "Chris George")
        self.assertEqual(alert.issue, Alert.ISSUE_TYPES.not_received)
        self.assertFalse(alert.is_resolved)
        self.assertIsNone(alert.remarks)
        self.assertEqual(alert.runnable.id, delivery.id)
        self.assertIsNone(alert.item_description)
开发者ID:v55448330,项目名称:eums,代码行数:29,代码来源:test_runnable.py

示例2: test_should_return_delivery_with_order_number

    def test_should_return_delivery_with_order_number(self):
        po = PurchaseOrderFactory(order_number=123456)
        po_item = PurchaseOrderItemFactory(purchase_order=po)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=po_item)

        self.assertEqual(delivery.number(), 123456)
开发者ID:raymondyan,项目名称:eums,代码行数:7,代码来源:test_delivery.py

示例3: test_should_return_default_answers_for_delivery

    def test_should_return_default_answers_for_delivery(self):
        delivery = DeliveryFactory()
        flow = FlowFactory(for_runnable_type="IMPLEMENTING_PARTNER")

        question_1 = MultipleChoiceQuestionFactory(label="deliveryReceived", flow=flow, text="Was Delivery Received?")
        question_2 = TextQuestionFactory(label="dateOfReceipt", flow=flow, text="When was Delivery Received?")

        OptionFactory(text="Yes", question=question_1)

        RunFactory(runnable=delivery)

        expected_multiple_choice_answer = {
            "question_label": question_1.label,
            "type": "multipleChoice",
            "text": question_1.text,
            "value": "",
            "options": ["Yes"],
            "position": question_1.position,
        }
        expected_text_answer = {
            "question_label": question_2.label,
            "type": "text",
            "text": question_2.text,
            "value": "",
            "position": question_2.position,
        }
        answers = delivery.answers()

        self.assertEqual(len(answers), 2)
        self.assertIn(expected_multiple_choice_answer, answers)
        self.assertIn(expected_text_answer, answers)
开发者ID:phoenix-zhu,项目名称:eums,代码行数:31,代码来源:test_delivery.py

示例4: test_should_return_answers_for_delivery_in_the_same_order_as_flow

    def test_should_return_answers_for_delivery_in_the_same_order_as_flow(self):
        delivery = DeliveryFactory()
        flow = FlowFactory(for_runnable_type="IMPLEMENTING_PARTNER")

        question_1 = MultipleChoiceQuestionFactory(
            label="deliveryReceived", flow=flow, text="Was Delivery Received?", position=3
        )
        question_2 = TextQuestionFactory(
            label="dateOfReceipt", flow=flow, text="When was Delivery Received?", position=1
        )
        question_3 = TextQuestionFactory(
            label="satisfiedWithProduct", flow=flow, text="Are you satisfied with product?", position=2
        )

        OptionFactory(text="No", question=question_1)
        OptionFactory(text="Yes", question=question_1)

        RunFactory(runnable=delivery)

        answers = delivery.answers()

        self.assertEqual(len(answers), 3)
        self.assertEqual(question_2.label, answers[0]["question_label"])
        self.assertEqual(question_3.label, answers[1]["question_label"])
        self.assertEqual(question_1.label, answers[2]["question_label"])
开发者ID:phoenix-zhu,项目名称:eums,代码行数:25,代码来源:test_delivery.py

示例5: test_should_return_delivery_with_waybill_number

    def test_should_return_delivery_with_waybill_number(self):
        release_order = ReleaseOrderFactory(waybill=98765)
        release_order_item = ReleaseOrderItemFactory(release_order=release_order)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=release_order_item)

        self.assertEqual(delivery.number(), 98765)
开发者ID:raymondyan,项目名称:eums,代码行数:7,代码来源:test_delivery.py

示例6: test_should_return_default_answers_for_delivery

    def test_should_return_default_answers_for_delivery(self):
        delivery = DeliveryFactory()
        flow = FlowFactory(label='IMPLEMENTING_PARTNER')

        question_1 = MultipleChoiceQuestionFactory(label='deliveryReceived', flow=flow, text='Was Delivery Received?')
        question_2 = TextQuestionFactory(label='dateOfReceipt', flow=flow, text='When was Delivery Received?')

        OptionFactory(text='Yes', question=question_1)

        RunFactory(runnable=delivery)

        expected_multiple_choice_answer = {
            'question_label': question_1.label,
            'type': 'multipleChoice',
            'text': question_1.text,
            'value': '',
            'options': ['Yes'],
            'position': question_1.position
        }
        expected_text_answer = {
            'question_label': question_2.label,
            'type': 'text',
            'text': question_2.text,
            'value': '',
            'position': question_2.position
        }
        answers = delivery.answers()

        self.assertEqual(len(answers), 2)
        self.assertIn(expected_multiple_choice_answer, answers)
        self.assertIn(expected_text_answer, answers)
开发者ID:raymondyan,项目名称:eums,代码行数:31,代码来源:test_delivery.py

示例7: test_should_dequeue_next_run_in_the_queue

    def test_should_dequeue_next_run_in_the_queue(self):
        first_delivery_to_be_answered = DeliveryFactory(track=True)
        contact = {'name': 'Some name', 'phone': '098765433'}
        first_delivery_to_be_answered.build_contact = MagicMock(return_value=contact)
        self._schedule_run_for(first_delivery_to_be_answered)
        second_delivery_to_be_answered = DeliveryFactory(track=True)
        self._schedule_run_for(second_delivery_to_be_answered)

        data = {
            'runnable': first_delivery_to_be_answered.id, 'answers': [
                {'question_label': 'deliveryReceived', 'value': 'Yes'}]
        }

        next_run = RunQueue.objects.filter(
            Q(contact_person_id=second_delivery_to_be_answered.contact_person_id) & Q(
                status='not_started')).order_by(
            '-run_delay').first()
        self.client.post(ENDPOINT_URL, data=json.dumps(data), content_type='application/json')

        first_runs = Run.objects.filter(runnable=first_delivery_to_be_answered)
        next_run = RunQueue.objects.get(id=next_run.id)

        self.assertEqual(len(first_runs), 2)
        self.assertEqual(next_run.status, 'started')
        self.assertTrue(self.mock_distribution_alert_raise.delay.called)
开发者ID:unicefuganda,项目名称:eums,代码行数:25,代码来源:test_web_answers_end_point.py

示例8: test_should_record_an_answer_of_type_multiple_choice_for_a_node_from_request_data

    def test_should_record_an_answer_of_type_multiple_choice_for_a_node_from_request_data(self, *_):
        uuid = '2ff9fab3-4c12-400e-a2fe-4551fa1ebc18'

        question = MultipleChoiceQuestionFactory(uuids=[uuid], text='Was item received?', label='productReceived',
                                                 flow=self.flow)

        Option.objects.get_or_create(text='Yes', question=question)
        Option.objects.get_or_create(text='No', question=question)

        delivery = DeliveryFactory()
        run = RunFactory(phone=self.PHONE, runnable=delivery)

        url_params = self._create_rapid_pro_url_params(self.PHONE, uuid, 'Yes', 'Yes', 'productReceived')

        response = self.client.post(HOOK_URL, url_params)

        expected_question = MultipleChoiceQuestion.objects.get(uuids=[uuid])
        yes_option = expected_question.option_set.get(text='Yes')

        answers = MultipleChoiceAnswer.objects.filter(question__uuids=[uuid], run=run)
        created_answer = answers.first()

        self.assertEqual(response.status_code, 200)
        self.assertEqual(created_answer.value, yes_option)
        self.assertEqual(delivery.answers()[0]['value'], created_answer.value.text)
开发者ID:phoenix-zhu,项目名称:eums,代码行数:25,代码来源:test_hook.py

示例9: test_should_return_false_when_delivery_run_was_cancelled

    def test_should_return_false_when_delivery_run_was_cancelled(self):
        delivery = DeliveryFactory()
        question = MultipleChoiceQuestionFactory(label='deliveryReceived')
        option = OptionFactory(text='Yes', question=question)
        run = RunFactory(runnable=delivery, status=Run.STATUS.cancelled)

        MultipleChoiceAnswerFactory(run=run, question=question, value=option)
        self.assertFalse(delivery.is_received())
开发者ID:raymondyan,项目名称:eums,代码行数:8,代码来源:test_delivery.py

示例10: pair_tracked_date_on_updated

    def pair_tracked_date_on_updated(self, pre_purchase_order_tracked_date=None, delivery_tracked_date=None):
        purchase_order = PurchaseOrderFactory(tracked_date=pre_purchase_order_tracked_date)
        po_item = PurchaseOrderItemFactory(purchase_order=purchase_order)
        delivery = DeliveryFactory(track=True, tracked_date=delivery_tracked_date)
        DeliveryNodeFactory(distribution_plan=delivery, item=po_item)
        delivery.save()

        updated_tracked_date = PurchaseOrder.objects.get(pk=purchase_order.id).tracked_date
        return updated_tracked_date
开发者ID:unicefuganda,项目名称:eums,代码行数:9,代码来源:test_delivery.py

示例11: test_should_return_false_when_delivery_is_not_received

    def test_should_return_false_when_delivery_is_not_received(self):
        delivery = DeliveryFactory()
        question = MultipleChoiceQuestionFactory(label="deliveryReceived")
        option = OptionFactory(text="No", question=question)
        run = RunFactory(runnable=delivery)

        self.assertFalse(delivery.is_received())

        MultipleChoiceAnswerFactory(run=run, question=question, value=option)

        self.assertFalse(delivery.is_received())
开发者ID:phoenix-zhu,项目名称:eums,代码行数:11,代码来源:test_delivery.py

示例12: test_should_schedule_implementing_partner_flow_if_runnable_is_delivery

    def test_should_schedule_implementing_partner_flow_if_runnable_is_delivery(self):
        delivery = DeliveryFactory()
        NodeFactory(distribution_plan=delivery, item=PurchaseOrderItemFactory())
        delivery.build_contact = MagicMock(return_value=self.contact)

        Runnable.objects.get = MagicMock(return_value=delivery)

        self.flow_scheduler.schedule_run_for(delivery)

        self.mocked_create_run.assert_called_with(self.contact, self.ip_flow,
                                                  ANY, ANY)
开发者ID:raymondyan,项目名称:eums,代码行数:11,代码来源:test_flow_scheduler.py

示例13: test_should_return_true_when_delivery_is_partially_received

    def test_should_return_true_when_delivery_is_partially_received(self):
        delivery = DeliveryFactory()
        question = MultipleChoiceQuestionFactory(label='deliveryReceived')
        option = OptionFactory(text='Yes', question=question)
        run = RunFactory(runnable=delivery)

        self.assertFalse(delivery.is_received())

        MultipleChoiceAnswerFactory(run=run, question=question, value=option)

        self.assertTrue(delivery.is_partially_received())
开发者ID:raymondyan,项目名称:eums,代码行数:11,代码来源:test_delivery.py

示例14: test_should_schedule_implementing_partner_flow_if_runnable_is_delivery

    def test_should_schedule_implementing_partner_flow_if_runnable_is_delivery(self):
        delivery = DeliveryFactory()
        NodeFactory(distribution_plan=delivery, item=PurchaseOrderItemFactory())
        delivery.build_contact = MagicMock(return_value=self.contact)

        Runnable.objects.get = MagicMock(return_value=delivery)

        schedule_run_for(delivery)

        mock_start_delivery_run.assert_called_with(contact_person=self.contact, flow=self.IMPLEMENTING_PARTNER_FLOW_ID,
                                                   item_description=ANY, sender=ANY)
开发者ID:phoenix-zhu,项目名称:eums,代码行数:11,代码来源:test_flow_scheduler.py

示例15: test_should_return_number_of_items_on_a_delivery

    def test_should_return_number_of_items_on_a_delivery(self):
        po = PurchaseOrderFactory(order_number=123456)
        po_item_one = PurchaseOrderItemFactory(purchase_order=po)
        po_item_two = PurchaseOrderItemFactory(purchase_order=po)
        delivery = DeliveryFactory()
        DeliveryNodeFactory(distribution_plan=delivery, item=po_item_one)

        self.assertEqual(delivery.number_of_items(), 1)

        DeliveryNodeFactory(distribution_plan=delivery, item=po_item_two)
        self.assertEqual(delivery.number_of_items(), 2)
开发者ID:raymondyan,项目名称:eums,代码行数:11,代码来源:test_delivery.py


注:本文中的eums.test.factories.delivery_factory.DeliveryFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。