本文整理汇总了Python中callisto.delivery.models.Report.owner方法的典型用法代码示例。如果您正苦于以下问题:Python Report.owner方法的具体用法?Python Report.owner怎么用?Python Report.owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类callisto.delivery.models.Report
的用法示例。
在下文中一共展示了Report.owner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_done_saves_anonymised_qs
# 需要导入模块: from callisto.delivery.models import Report [as 别名]
# 或者: from callisto.delivery.models.Report import owner [as 别名]
def test_done_saves_anonymised_qs(self, mockReport):
self.maxDiff = None
radio_button_q = RadioButton.objects.create(text="this is a radio button question", page=self.page2)
for i in range(5):
Choice.objects.create(text="This is choice %i" % i, question=radio_button_q)
wizard = EncryptedFormWizard.wizard_factory()()
PageOneForm = wizard.form_list[0]
PageTwoForm = wizard.form_list[1]
KeyForm = wizard.form_list[2]
page_one = PageOneForm({'question_%i' % self.question1.pk: 'test answer'})
page_one.is_valid()
page_two = PageTwoForm({'question_%i' % self.question2.pk: 'another answer to a different question',
'question_%i' % radio_button_q.pk: radio_button_q.choice_set.all()[2].pk})
page_two.is_valid()
key_form = KeyForm({'key': self.report_key, 'key2': self.report_key})
key_form.is_valid()
mock_report = Report()
mock_report.save = Mock()
mock_report.owner = self.request.user
mockReport.return_value = mock_report
self._get_wizard_response(wizard, form_list=[page_one, page_two, key_form], request=self.request)
示例2: test_wizard_done_is_called
# 需要导入模块: from callisto.delivery.models import Report [as 别名]
# 或者: from callisto.delivery.models.Report import owner [as 别名]
def test_wizard_done_is_called(self, mockReport):
mock_report = Report()
mock_report.id = 1
mock_report.owner = self.request.user
mockReport.return_value = mock_report
wizard = EncryptedFormWizard.wizard_factory()()
PageOneForm = wizard.form_list[0]
PageTwoForm = wizard.form_list[1]
KeyForm = wizard.form_list[2]
page_one = PageOneForm({'question_%i' % self.question1.pk: ""})
page_one.is_valid()
page_two = PageTwoForm({'question_%i' % self.question2.pk: ""})
page_two.is_valid()
key_form = KeyForm({'key': self.report_key, 'key2': self.report_key})
key_form.is_valid()
form_list = [page_one, page_two, key_form]
wizard.processed_answers = wizard.process_answers(form_list=form_list, form_dict=dict(enumerate(form_list)))
response = wizard.done(form_list=form_list, form_dict=dict(enumerate(form_list)), request=self.request)
self.assertContains(response, 1)
示例3: test_done_serializes_questions
# 需要导入模块: from callisto.delivery.models import Report [as 别名]
# 或者: from callisto.delivery.models.Report import owner [as 别名]
def test_done_serializes_questions(self, mockReport):
self.maxDiff = None
radio_button_q = RadioButton.objects.create(text="this is a radio button question", page=self.page2)
for i in range(5):
Choice.objects.create(text="This is choice %i" % i, question=radio_button_q)
wizard = EncryptedFormWizard.wizard_factory()()
PageOneForm = wizard.form_list[0]
PageTwoForm = wizard.form_list[1]
KeyForm = wizard.form_list[2]
page_one = PageOneForm({'question_%i' % self.question1.pk: 'test answer'})
page_one.is_valid()
page_two = PageTwoForm({'question_%i' % self.question2.pk: 'another answer to a different question',
'question_%i' % radio_button_q.pk: radio_button_q.choice_set.all()[2].pk})
page_two.is_valid()
key_form = KeyForm({'key': self.report_key, 'key2': self.report_key})
key_form.is_valid()
object_ids = [choice.pk for choice in radio_button_q.choice_set.all()]
selected_id = object_ids[2]
object_ids.insert(0, radio_button_q.pk)
object_ids.insert(0, selected_id)
object_ids.insert(0, self.question2.pk)
object_ids.insert(0, self.question1.pk)
json_report = """[
{ "answer": "test answer",
"id": %i,
"section": 1,
"question_text": "first question",
"type": "SingleLineText"
},
{ "answer": "another answer to a different question",
"id": %i,
"section": 1,
"question_text": "2nd question",
"type": "SingleLineText"
},
{ "answer": "%i",
"id": %i,
"section": 1,
"question_text": "this is a radio button question",
"choices": [{"id": %i, "choice_text": "This is choice 0"},
{"id": %i, "choice_text": "This is choice 1"},
{"id": %i, "choice_text": "This is choice 2"},
{"id": %i, "choice_text": "This is choice 3"},
{"id": %i, "choice_text": "This is choice 4"}],
"type": "RadioButton"
}
]""" % tuple(object_ids)
mock_report = Report()
mock_report.save = Mock()
mock_report.owner = self.request.user
mockReport.return_value = mock_report
def check_json():
self.assertEqual(sort_json(mock_report.decrypted_report(self.report_key)),
sort_json(json_report))
mock_report.save.side_effect = check_json
self._get_wizard_response(wizard, form_list=[page_one, page_two, key_form], request=self.request)
mock_report.save.assert_any_call()
示例4: test_reports_have_owners
# 需要导入模块: from callisto.delivery.models import Report [as 别名]
# 或者: from callisto.delivery.models.Report import owner [as 别名]
def test_reports_have_owners(self):
report = Report()
report.owner = self.user
report.save()
self.assertIn(report, self.user .report_set.all())