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


Python delivery_node_factory.DeliveryNodeFactory类代码示例

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


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

示例1: test_should_create_alert_with_item_description

    def test_should_create_alert_with_item_description(self, mock_contact):
        purchase_order = PurchaseOrderFactory(order_number=5678)
        description = "some description"
        item = ItemFactory(description=description)
        purchase_order_item = PurchaseOrderItemFactory(purchase_order=purchase_order, item=item)
        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

        node = DeliveryNodeFactory(item=purchase_order_item, consignee=consignee, contact_person_id=contact_person_id)

        node.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, node)
        self.assertEqual(alert.item_description, description)
开发者ID:v55448330,项目名称:eums,代码行数:30,代码来源:test_delivery_node.py

示例2: test_gets_all_response_for_node_consignee

    def test_gets_all_response_for_node_consignee(self):
        multichoice_question = MultipleChoiceQuestionFactory(label='productReceived')
        yes_option = OptionFactory(text='Yes', question=multichoice_question)
        no_option = OptionFactory(text='No', question=multichoice_question)

        sugar = ItemFactory(description='Sugar')
        salt = ItemFactory(description='Salt')

        numeric_question = NumericQuestionFactory(label='AmountReceived')
        item = SalesOrderItemFactory(item=salt, description='10 bags of salt')

        salt_node = DeliveryNodeFactory(quantity=100, item=PurchaseOrderItemFactory(sales_order_item=item))
        run = RunFactory(runnable=salt_node, status='completed')

        sugar_item = SalesOrderItemFactory(item=sugar, description='10 bags of sugar')
        sugar_node = DeliveryNodeFactory(quantity=100, item=PurchaseOrderItemFactory(sales_order_item=sugar_item))
        sugar_run = RunFactory(runnable=sugar_node, status='completed')

        multiple_answer_one = MultipleChoiceAnswerFactory(run=run, question=multichoice_question, value=yes_option)
        numeric_answer_one = NumericAnswerFactory(run=run, value=80, question=numeric_question)

        multiple_answer_two = MultipleChoiceAnswerFactory(run=sugar_run, question=multichoice_question, value=no_option)
        numeric_answer_two = NumericAnswerFactory(run=sugar_run, value=80, question=numeric_question)
        salt_node_responses = salt_node.responses()
        sugar_node_responses = sugar_node.responses()

        self.assertIn(multiple_answer_one, salt_node_responses[run])
        self.assertIn(numeric_answer_one, salt_node_responses[run])

        self.assertIn(multiple_answer_two, sugar_node_responses[sugar_run])
        self.assertIn(numeric_answer_two, sugar_node_responses[sugar_run])
开发者ID:v55448330,项目名称:eums,代码行数:31,代码来源:test_runnable.py

示例3: test_delivery_node_knows_its_item_description

    def test_delivery_node_knows_its_item_description(self):
        purchase_order = PurchaseOrderFactory(order_number=200)
        description = "some description"
        item = ItemFactory(description=description)
        po_node = DeliveryNodeFactory(item=PurchaseOrderItemFactory(purchase_order=purchase_order, item=item))

        self.assertEqual(po_node.item_description(), description)
开发者ID:v55448330,项目名称:eums,代码行数:7,代码来源:test_delivery_node.py

示例4: test_should_get_sender_name

    def test_should_get_sender_name(self):
        sender_name = 'Save the children'
        root_node = DeliveryNodeFactory(consignee=ConsigneeFactory(name=sender_name))
        self.assertEqual(root_node.sender_name(), 'UNICEF')

        node = DeliveryNodeFactory(parents=[(root_node, 5)])
        self.assertEqual(node.sender_name(), sender_name)
开发者ID:v55448330,项目名称:eums,代码行数:7,代码来源:test_delivery_node.py

示例5: test_should_delete_node_from_elasticsearch_when_deleted

    def test_should_delete_node_from_elasticsearch_when_deleted(self):
        node = DeliveryNodeFactory()
        SyncInfo.objects.create(status=SyncInfo.STATUS.SUCCESSFUL)

        node.delete()
        nodes_to_delete = list_nodes_to_delete()

        self.assertIn(node.id, nodes_to_delete)
开发者ID:phoenix-zhu,项目名称:eums,代码行数:8,代码来源:test_sync_data_generators.py

示例6: test_returned_nodes_should_have_order_type_field

    def test_returned_nodes_should_have_order_type_field(self):
        po_node = DeliveryNodeFactory(item=PurchaseOrderItemFactory(purchase_order=(PurchaseOrderFactory())))
        ro_node = DeliveryNodeFactory(item=ReleaseOrderItemFactory(release_order=(ReleaseOrderFactory())))

        response = self.client.get(ENDPOINT_URL)
        node_order_types = [node['order_type'] for node in response.data]

        self.assertItemsEqual([po_node.type(), ro_node.type()], node_order_types)
开发者ID:unicefuganda,项目名称:eums,代码行数:8,代码来源:test_delivery_node_endpoint.py

示例7: test_should_delete_tracked_node_on_update_with_zero_quantity

    def test_should_delete_tracked_node_on_update_with_zero_quantity(self):
        node = DeliveryNodeFactory(quantity=10, track=True)
        self.assertEqual(DeliveryNode.objects.count(), 1)

        node.quantity = 0
        returned_node = node.save()
        self.assertEqual(DeliveryNode.objects.count(), 0)
        self.assertTrue(isinstance(returned_node, DeliveryNode))
开发者ID:v55448330,项目名称:eums,代码行数:8,代码来源:test_delivery_node.py

示例8: test_should_know_its_order_number

    def test_should_know_its_order_number(self):
        purchase_order = PurchaseOrderFactory(order_number=200)
        po_node = DeliveryNodeFactory(item=PurchaseOrderItemFactory(purchase_order=purchase_order))
        self.assertEqual(po_node.order_number(), 200)

        release_order = ReleaseOrderFactory(waybill=300)
        ro_node = DeliveryNodeFactory(item=ReleaseOrderItemFactory(release_order=release_order))
        self.assertEqual(ro_node.order_number(), 300)
开发者ID:v55448330,项目名称:eums,代码行数:8,代码来源:test_delivery_node.py

示例9: test_should_ignore_updates_to_quantity_on_non_root_node

    def test_should_ignore_updates_to_quantity_on_non_root_node(self):
        node_one = DeliveryNodeFactory()
        node = DeliveryNodeFactory(parents=[{'id': node_one.id, 'quantity': 7}])

        node.quantity = 50
        node.save()

        self.assertEqual(node.quantity_in(), 7)
开发者ID:v55448330,项目名称:eums,代码行数:8,代码来源:test_delivery_node.py

示例10: test_should_compute_quantity_out_from_outgoing_arcs

    def test_should_compute_quantity_out_from_outgoing_arcs(self):
        node_one = DeliveryNodeFactory(quantity=50)
        node_two = DeliveryNodeFactory()
        ArcFactory(source=node_one, target=node_two, quantity=50)
        self.assertEqual(node_one.quantity_out(), 50)
        self.assertEqual(node_two.quantity_out(), 0)

        Arc.objects.all().delete()
        self.assertEqual(node_one.quantity_out(), 0)
开发者ID:v55448330,项目名称:eums,代码行数:9,代码来源:test_delivery_node.py

示例11: test_node_flow_is_middleman_for_non_end_user_node

    def test_node_flow_is_middleman_for_non_end_user_node(self):
        middleman_flow = FlowFactory(label=Flow.Label.MIDDLE_MAN)
        runnable = DeliveryNodeFactory(tree_position=Flow.Label.IMPLEMENTING_PARTNER)

        self.assertEqual(runnable.flow(), middleman_flow)

        runnable.tree_position = Flow.Label.MIDDLE_MAN

        self.assertEqual(runnable.flow(), middleman_flow)
开发者ID:v55448330,项目名称:eums,代码行数:9,代码来源:test_delivery_node.py

示例12: test_should_return_list_of_children

    def test_should_return_list_of_children(self):
        parent_node = DeliveryNodeFactory(quantity=100)
        child_one = DeliveryNodeFactory(parents=[(parent_node, 30)])
        child_two = DeliveryNodeFactory(parents=[(parent_node, 20)])

        children = parent_node.children()
        self.assertEqual(children.count(), 2)
        self.assertIn(child_one, children)
        self.assertIn(child_two, children)
开发者ID:v55448330,项目名称:eums,代码行数:9,代码来源:test_delivery_node.py

示例13: test_should_update_delivery_node_parents

    def test_should_update_delivery_node_parents(self):
        node_one = DeliveryNodeFactory()
        node = DeliveryNodeFactory(parents=[{'id': node_one.id, 'quantity': 5}])

        changes = {'parents': [{'id': node_one.id, 'quantity': 8}]}
        path = '%s%d/' % (ENDPOINT_URL, node.id)
        response = self.client.patch(path, data=json.dumps(changes), content_type='application/json')

        self.assertEqual(response.status_code, 200)
        self.assertEqual(node.quantity_in(), 8)
开发者ID:unicefuganda,项目名称:eums,代码行数:10,代码来源:test_delivery_node_endpoint.py

示例14: test_should_add_changed_node_to_sync_data

    def test_should_add_changed_node_to_sync_data(self, *_):
        node = DeliveryNodeFactory(location='Kampala')
        SyncInfo.objects.create(status=SyncInfo.STATUS.SUCCESSFUL)
        list_nodes_to_update()

        node.location = 'Changed location'
        node.save()
        nodes_to_sync = list_nodes_to_update()

        self.assertIn(node, nodes_to_sync)
开发者ID:phoenix-zhu,项目名称:eums,代码行数:10,代码来源:test_sync_data_generators.py

示例15: test_should_compute_quantity_in_from_incoming_arcs

    def test_should_compute_quantity_in_from_incoming_arcs(self):
        node = DeliveryNodeFactory(quantity=0)
        ArcFactory(source=None, target=node, quantity=50)
        self.assertEqual(node.quantity_in(), 50)

        ArcFactory(source=None, target=node, quantity=50)
        self.assertEqual(node.quantity_in(), 100)

        Arc.objects.all().delete()
        self.assertEqual(node.quantity_in(), 0)
开发者ID:v55448330,项目名称:eums,代码行数:10,代码来源:test_delivery_node.py


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