本文整理汇总了Python中eums.test.factories.delivery_factory.DeliveryFactory.node_answers方法的典型用法代码示例。如果您正苦于以下问题:Python DeliveryFactory.node_answers方法的具体用法?Python DeliveryFactory.node_answers怎么用?Python DeliveryFactory.node_answers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eums.test.factories.delivery_factory.DeliveryFactory
的用法示例。
在下文中一共展示了DeliveryFactory.node_answers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_return_answers_for_all_first_level_nodes_in_a_delivery
# 需要导入模块: from eums.test.factories.delivery_factory import DeliveryFactory [as 别名]
# 或者: from eums.test.factories.delivery_factory.DeliveryFactory import node_answers [as 别名]
def test_should_return_answers_for_all_first_level_nodes_in_a_delivery(self):
delivery = DeliveryFactory()
node_one = DeliveryNodeFactory(distribution_plan=delivery)
node_two = DeliveryNodeFactory(distribution_plan=delivery)
flow = FlowFactory(label='WEB')
question_1 = MultipleChoiceQuestionFactory(text='Was the item received?', label='itemReceived', flow=flow,
position=1)
option_1 = OptionFactory(text='Yes', question=question_1)
question_2 = NumericQuestionFactory(text='How much was received?', label='amountReceived', flow=flow)
question_3 = MultipleChoiceQuestionFactory(text='What is the quality of the product?', label='qualityOfProduct',
flow=flow, position=3)
option_3 = OptionFactory(text='Damaged', question=question_3)
question_4 = MultipleChoiceQuestionFactory(text='Are you satisfied with the product?',
label='satisfiedWithProduct', flow=flow, position=4)
option_4 = OptionFactory(text='Yes', question=question_4)
question_5 = TextQuestionFactory(text='Remarks', label='additionalDeliveryComments',
flow=flow, position=5)
run_one = RunFactory(runnable=node_one)
MultipleChoiceAnswerFactory(question=question_1, run=run_one, value=option_1)
NumericAnswerFactory(question=question_2, run=run_one, value=5)
MultipleChoiceAnswerFactory(question=question_3, run=run_one, value=option_3)
MultipleChoiceAnswerFactory(question=question_4, run=run_one, value=option_4)
TextAnswerFactory(question=question_5, run=run_one, value="Answer")
run_two = RunFactory(runnable=node_two)
MultipleChoiceAnswerFactory(question=question_1, run=run_two, value=option_1)
NumericAnswerFactory(question=question_2, run=run_two, value=3)
MultipleChoiceAnswerFactory(question=question_3, run=run_two, value=option_3)
MultipleChoiceAnswerFactory(question=question_4, run=run_two, value=option_4)
TextAnswerFactory(question=question_5, run=run_two, value="Answer")
node_answers = delivery.node_answers()
expected_multiple_choice_answer = {
'question_label': question_1.label,
'type': 'multipleChoice',
'text': question_1.text,
'value': 'Yes',
'options': ['Yes'],
'position': question_1.position
}
expected_text_answer = {
'question_label': question_5.label,
'type': 'text',
'text': question_5.text,
'value': 'Answer',
'position': question_5.position
}
self.assertEqual(len(node_answers), 2)
self.assertIn(node_answers[0]['id'], [node_one.id, node_two.id])
self.assertEqual(len(node_answers[0]['answers']), 5)
self.assertIn(expected_multiple_choice_answer, node_answers[0]['answers'])
self.assertIn(node_answers[1]['id'], [node_one.id, node_two.id])
self.assertEqual(len(node_answers[1]['answers']), 5)
self.assertIn(expected_text_answer, node_answers[1]['answers'])
示例2: test_should_return_answers_for_all_first_level_nodes_in_a_delivery
# 需要导入模块: from eums.test.factories.delivery_factory import DeliveryFactory [as 别名]
# 或者: from eums.test.factories.delivery_factory.DeliveryFactory import node_answers [as 别名]
def test_should_return_answers_for_all_first_level_nodes_in_a_delivery(self):
delivery = DeliveryFactory()
node_one = DeliveryNodeFactory(distribution_plan=delivery)
node_two = DeliveryNodeFactory(distribution_plan=delivery)
flow = FlowFactory(for_runnable_type="WEB")
question_1 = MultipleChoiceQuestionFactory(
text="Was the item received?", label="itemReceived", flow=flow, position=1
)
option_1 = OptionFactory(text="Yes", question=question_1)
question_2 = NumericQuestionFactory(text="How much was received?", label="amountReceived", flow=flow)
question_3 = MultipleChoiceQuestionFactory(
text="What is the quality of the product?", label="qualityOfProduct", flow=flow, position=3
)
option_3 = OptionFactory(text="Damaged", question=question_3)
question_4 = MultipleChoiceQuestionFactory(
text="Are you satisfied with the product?", label="satisfiedWithProduct", flow=flow, position=4
)
option_4 = OptionFactory(text="Yes", question=question_4)
question_5 = TextQuestionFactory(text="Remarks", label="additionalDeliveryComments", flow=flow, position=5)
run_one = RunFactory(runnable=node_one)
MultipleChoiceAnswerFactory(question=question_1, run=run_one, value=option_1)
NumericAnswerFactory(question=question_2, run=run_one, value=5)
MultipleChoiceAnswerFactory(question=question_3, run=run_one, value=option_3)
MultipleChoiceAnswerFactory(question=question_4, run=run_one, value=option_4)
TextAnswerFactory(question=question_5, run=run_one, value="Answer")
run_two = RunFactory(runnable=node_two)
MultipleChoiceAnswerFactory(question=question_1, run=run_two, value=option_1)
NumericAnswerFactory(question=question_2, run=run_two, value=3)
MultipleChoiceAnswerFactory(question=question_3, run=run_two, value=option_3)
MultipleChoiceAnswerFactory(question=question_4, run=run_two, value=option_4)
TextAnswerFactory(question=question_5, run=run_two, value="Answer")
node_answers = delivery.node_answers()
expected_multiple_choice_answer = {
"question_label": question_1.label,
"type": "multipleChoice",
"text": question_1.text,
"value": "Yes",
"options": ["Yes"],
"position": question_1.position,
}
expected_text_answer = {
"question_label": question_5.label,
"type": "text",
"text": question_5.text,
"value": "Answer",
"position": question_5.position,
}
self.assertEqual(len(node_answers), 2)
self.assertIn(node_answers[0]["id"], [node_one.id, node_two.id])
self.assertEqual(len(node_answers[0]["answers"]), 5)
self.assertIn(expected_multiple_choice_answer, node_answers[0]["answers"])
self.assertIn(node_answers[1]["id"], [node_one.id, node_two.id])
self.assertEqual(len(node_answers[1]["answers"]), 5)
self.assertIn(expected_text_answer, node_answers[1]["answers"])