def test_should_start_a_flow_run_for_a_contact(self, mock_post, *_): mock_post.return_value = FakeResponse(self.fake_json, 201) expected_headers = {'Authorization': 'Token %s' % settings.RAPIDPRO_API_TOKEN, 'Content-Type': 'application/json'} start_delivery_run(contact_person=contact, item_description=item_description, sender=sender, flow=self.flow.rapid_pro_id) mock_post.assert_called_with(settings.RAPIDPRO_URLS['RUNS'], data=self.expected_payload, headers=expected_headers)
def _schedule_run(node_line_item_id): node_line_item = DistributionPlanLineItem.objects.get(id=node_line_item_id) node = node_line_item.distribution_plan_node start_delivery_run( sender=__get_sender_name(node), item_description=node_line_item.item.description, consignee=node.consignee.build_contact() )
def _schedule_run(node_id): node = DistributionPlanNode.objects.get(id=node_id) flow = _select_flow_for(node) start_delivery_run( sender=_get_sender_name(node), item_description=node.item.item.description, contact_person=node.build_contact(), flow=flow.rapid_pro_id )
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_post_to_fake_rapid_pro_when_starting_a_run(self, mock_post, *_): mock_post.return_value = None start_delivery_run(contact_person=contact, item_description=item_description, sender=sender, flow=self.flow.rapid_pro_id) mock_post.assert_called()
def _schedule_run(node_line_item_id): node_line_item = DistributionPlanLineItem.objects.get(id=node_line_item_id) node = node_line_item.distribution_plan_node start_delivery_run(sender=__get_sender_name(node), item_description=node_line_item.item.description, consignee=node.consignee.build_contact())
def test_should_post_to_fake_rapid_pro_when_starting_a_run(self): start_delivery_run(consignee=contact, item_description=item_description, sender=sender) verify(runs).post(data=any())
def test_should_start_a_flow_run_for_a_contact(self): expected_headers = {'Authorization': 'Token %s' % settings.RAPIDPRO_API_TOKEN} start_delivery_run(consignee=contact, item_description=item_description, sender=sender) verify(requests).post(settings.RAPIDPRO_URLS['RUNS'], data=self.expected_payload, headers=expected_headers)