本文整理汇总了Python中huxley.accounts.forms.registration.RegistrationForm.add_committee_preferences方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationForm.add_committee_preferences方法的具体用法?Python RegistrationForm.add_committee_preferences怎么用?Python RegistrationForm.add_committee_preferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类huxley.accounts.forms.registration.RegistrationForm
的用法示例。
在下文中一共展示了RegistrationForm.add_committee_preferences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_committee_preferences
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import add_committee_preferences [as 别名]
def test_add_committee_preferences(self):
""" Tests that adding committee preferences works """
params = self.valid_params.copy()
params['school_name'] = 'CommitteeTest1'
form = RegistrationForm(params)
# No committee preferences
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertTrue(form.add_committee_preferences(school))
self.assertEqual(len(school.committeepreferences.all()), 0)
# Some preferences
params['committee_prefs'] = [13, 14, 19]
params['school_name'] = 'CommitteeTest2'
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertTrue(form.add_committee_preferences(school))
self.assertEqual(len(school.committeepreferences.all()), 3)
for committee in school.committeepreferences.all():
self.assertIn(committee.id, params['committee_prefs'])