本文整理汇总了Python中questionnaire.services.users.UserQuestionnaireService.submit方法的典型用法代码示例。如果您正苦于以下问题:Python UserQuestionnaireService.submit方法的具体用法?Python UserQuestionnaireService.submit怎么用?Python UserQuestionnaireService.submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类questionnaire.services.users.UserQuestionnaireService
的用法示例。
在下文中一共展示了UserQuestionnaireService.submit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_submit_changes_draft_answers_to_submitted_and_not_create_new_instances
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import submit [as 别名]
def test_submit_changes_draft_answers_to_submitted_and_not_create_new_instances(self):
data = self.data
old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2, **self.initial)
old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3, **self.initial)
answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
answer_group.answer.add(old_primary, old_answer_1, old_answer_2)
user_service = UserQuestionnaireService(self.user.user_profile.country, self.questionnaire)
user_service.submit()
primary = MultiChoiceAnswer.objects.get(response__id=int(data['MultiChoice-0-response']), question=self.question1)
answer_1 = NumericalAnswer.objects.get(response=int(data['Number-0-response']), question=self.question2)
answer_2 = NumericalAnswer.objects.get(response=int(data['Number-1-response']), question=self.question3)
self.assertEqual(old_primary.id, primary.id)
self.assertEqual(Answer.SUBMITTED_STATUS, primary.status)
self.assertEqual(old_answer_1.id, answer_1.id)
self.assertEqual(Answer.SUBMITTED_STATUS, answer_1.status)
self.assertEqual(old_answer_2.id, answer_2.id)
self.assertEqual(Answer.SUBMITTED_STATUS, answer_2.status)
answer_group = AnswerGroup.objects.filter(grouped_question=self.question_group)
self.assertEqual(1, answer_group.count())
示例2: test_user_knows_answer_version_of_questionnaire_is_plus_1_of_the_latest_submitted_answers
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import submit [as 别名]
def test_user_knows_answer_version_of_questionnaire_is_plus_1_of_the_latest_submitted_answers(self):
data = self.data.copy()
old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2, **self.initial)
old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3, **self.initial)
answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
answer_group.answer.add(old_primary, old_answer_1, old_answer_2)
user_service = UserQuestionnaireService(self.user, self.questionnaire)
user_service.submit()
self.assertEqual(self.initial['version']+1, user_service.answer_version())
示例3: test_user_knows_if_he_should_see_preview_when_status_is_submitted
# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import submit [as 别名]
def test_user_knows_if_he_should_see_preview_when_status_is_submitted(self):
data = self.data
old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2,
**self.initial)
old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3,
**self.initial)
answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
answer_group.answer.add(old_primary, old_answer_1, old_answer_2)
user_country = self.user.user_profile.country
user_service = UserQuestionnaireService(user_country, self.questionnaire)
self.assertFalse(user_service.preview())
user_service.submit()
self.assertTrue(user_service.preview())