本文整理汇总了Python中survey.models.Survey.__unicode__方法的典型用法代码示例。如果您正苦于以下问题:Python Survey.__unicode__方法的具体用法?Python Survey.__unicode__怎么用?Python Survey.__unicode__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类survey.models.Survey
的用法示例。
在下文中一共展示了Survey.__unicode__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SurveyModel
# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import __unicode__ [as 别名]
class SurveyModel(TestCase):
"""Test Survey, Section, Branching, Result, ResultAggregate Model"""
fixtures = ['auth_user.json', 'gateway.json', 'dialer_setting.json',
'user_profile.json', # 'contenttype.json',
'phonebook.json', 'contact.json',
'dnc_list.json', 'dnc_contact.json',
'campaign.json', 'subscriber.json',
'callrequest.json', 'voipcall.json',
'survey_template.json', 'survey.json',
'section_template.json', 'section.json',
'branching.json',
]
def setUp(self):
self.user = User.objects.get(username='admin')
# Survey_template model
self.survey_template = Survey_template(
name='test_survey',
user=self.user,
)
self.survey_template.save()
# Survey model
self.survey = Survey(
name='test_survey',
user=self.user,
)
self.survey.save()
self.assertEqual(self.survey.__unicode__(), u'test_survey')
# Section_template
self.section_template = Section_template.objects.get(pk=1)
self.section_template.survey.name = 'New Survey'
self.section_template.save()
# Section model
self.section = Section.objects.get(pk=1)
self.section.save()
self.assertTrue(self.section.__unicode__())
# Branching_template model
self.branching_template = Branching_template(
keys=5,
section=self.section_template,
)
self.branching_template.save()
# Branching model
self.branching = Branching(
keys=5,
section=self.section,
)
self.branching.save()
self.assertTrue(self.branching.__unicode__())
# Result model
self.result = Result(
section=self.section,
callrequest_id=1,
response='apple'
)
self.result.save()
self.assertEqual(
self.result.__unicode__(), '[1] [1] call transfer = apple')
# ResultAggregate model
self.result_aggregate = ResultAggregate(
survey=self.survey,
section=self.section,
count=1,
response='apple'
)
self.result_aggregate.save()
self.assertEqual(
self.result_aggregate.__unicode__(), '[1] [1] call transfer = apple')
def test_survey_forms(self):
self.assertEqual(self.survey_template.name, "test_survey")
#self.assertEqual(self.section_template.survey, self.survey_template)
self.assertEqual(self.branching_template.section, self.section_template)
self.assertEqual(self.result.section, self.section)
form = PlayMessageSectionForm(self.user, instance=self.section_template)
obj = form.save(commit=False)
obj.question = "test question"
obj.type = 1
obj.survey = self.survey_template
obj.save()
form = MultipleChoiceSectionForm(self.user, instance=self.section_template)
obj = form.save(commit=False)
obj.type = 2
obj.question = "test question"
obj.key_0 = "apple"
obj.survey = self.survey_template
obj.save()
form = RatingSectionForm(self.user,
#.........这里部分代码省略.........