本文整理汇总了Python中huxley.accounts.forms.registration.RegistrationForm.create_school方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationForm.create_school方法的具体用法?Python RegistrationForm.create_school怎么用?Python RegistrationForm.create_school使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类huxley.accounts.forms.registration.RegistrationForm
的用法示例。
在下文中一共展示了RegistrationForm.create_school方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_country_preferences
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_add_country_preferences(self):
""" Tests that adding country preferences works """
# Initialization
params = self.valid_params.copy()
for i in xrange(1,11):
params['country_pref' + str(i)] = 0
# No preferences at all
params['school_name'] = 'CountryTest1'
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertTrue(form.add_country_preferences(school))
prefs = CountryPreference.objects.filter(school=school)
self.assertEqual(len(prefs), 0)
# Couple of random preferences scattered around
params['school_name'] = 'CountryTest2'
params['country_pref1'] = 2
params['country_pref3'] = 10
params['country_pref7'] = 7
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertTrue(form.add_country_preferences(school))
prefs = CountryPreference.objects.filter(school=school)
self.assertEqual(len(prefs), 3)
self.assertEqual(prefs[0].country.id, params['country_pref1'])
self.assertEqual(prefs[1].country.id, params['country_pref3'])
self.assertEqual(prefs[2].country.id, params['country_pref7'])
示例2: test_school_uniqueness
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_school_uniqueness(self):
""" Tests that the school name checks if it's unique """
params = self.valid_params.copy()
params['school_name'] = 'MySchool'
# This should be valid, as 'abcdef' should be unique
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
form.create_school()
# This shouldn't be valid.
form = RegistrationForm(params)
self.assertFalse(form.is_valid())
self.assertEqual(len(form.errors), 1)
self.assertIn('school_name', form.errors)
self.assertItemsEqual(form.errors['school_name'], ['A school with the name "%s" has already been registered.' % (params['school_name'])])
# Now try another valid one
params['school_name'] = 'MySchool2'
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
示例3: test_school_uniqueness
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_school_uniqueness(self):
""" Tests that the school name checks if it's unique """
params = self.valid_params.copy()
params["SchoolName"] = "MySchool"
# This should be valid, as "abcdef" should be unique
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
form.create_school()
# This shouldn't be valid.
form = RegistrationForm(params)
self.assertFalse(form.is_valid())
self.assertEqual(len(form.errors), 1)
self.assertIn("SchoolName", form.errors)
self.assertItemsEqual(form.errors["SchoolName"], ["A school with the name '%s' has already been registered." % (params["SchoolName"])])
# Now try another valid one
params["SchoolName"] = "MySchool2"
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
示例4: test_add_committee_preferences
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [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'])
示例5: test_create_advisor_profile
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_create_advisor_profile(self):
""" Tests that an advisor profile for a user and a school is successfully created upon registration """
params = self.valid_params.copy()
params["Username"] = "advisor_profile_test"
params["SchoolName"] = "advisor_profile_test"
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
user = form.create_user()
school = form.create_school()
profile = form.create_advisor_profile(user, school)
self.assertFalse(profile is None)
self.assertEqual(profile.user, user)
self.assertEqual(profile.school, school)
示例6: test_create_school
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_create_school(self):
""" Tests that the form creates a school object in the DB properly """
# Test that American schools are created properly
params = self.valid_params.copy()
params['school_name'] = 'GirlsGeneration'
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertFalse(school is None)
self.assertEqual(school.name, params['school_name'])
self.assertEqual(school.address, params['school_address'])
self.assertEqual(school.city, params['school_city'])
self.assertEqual(school.state, params['school_state'])
self.assertEqual(school.zip_code, str(params['school_zip']))
self.assertEqual(school.primary_name, params['primary_name'])
self.assertEqual(school.primary_email, params['primary_email'])
self.assertEqual(school.primary_phone, params['primary_phone'])
self.assertEqual(school.program_type, params['program_type'])
self.assertEqual(school.times_attended, params['times_attended'])
self.assertEqual(school.min_delegation_size, params['min_delegation_size'])
self.assertEqual(school.max_delegation_size, params['max_delegation_size'])
self.assertFalse(school.international)
# Make sure state isn't an empty string, or a string of spaces
# Bit unnecessary though
matches = re.match('^\s*$', school.state)
self.assertTrue(matches is None)
if 'secondary_name' in params:
self.assertEqual(school.secondary_name, params['secondary_name'])
if 'secondary_email' in params:
self.assertEqual(school.secondary_email, params['secondary_email'])
if 'secondary_phone' in params:
self.assertEqual(school.secondary_phone, params['secondary_phone'])
# Check to see that it's in the database as well
schools_in_db = School.objects.filter(name=params['school_name'])
self.assertGreater(len(schools_in_db), 0)
self.assertEqual(schools_in_db[0], school)
# Test international school creation
params['school_name'] = 'GirlsGenerationInternational'
params['school_country'] = '10'
params['school_location'] = School.LOCATION_INTERNATIONAL
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertFalse(school is None)
self.assertEqual(school.name, params['school_name'])
self.assertEqual(school.address, params['school_address'])
self.assertEqual(school.city, params['school_city'])
self.assertEqual(school.zip_code, str(params['school_zip']))
self.assertEqual(school.country, params['school_country'])
self.assertEqual(school.primary_name, params['primary_name'])
self.assertEqual(school.primary_email, params['primary_email'])
self.assertEqual(school.primary_phone, params['primary_phone'])
self.assertEqual(school.program_type, params['program_type'])
self.assertEqual(school.times_attended, params['times_attended'])
self.assertEqual(school.min_delegation_size, params['min_delegation_size'])
self.assertEqual(school.max_delegation_size, params['max_delegation_size'])
self.assertTrue(school.international)
if 'school_state' in params:
self.assertEqual(school.state, params['school_state'])
if 'secondary_name' in params:
self.assertEqual(school.secondary_name, params['secondary_name'])
if 'secondary_email' in params:
self.assertEqual(school.secondary_email, params['secondary_email'])
if 'secondary_phone' in params:
self.assertEqual(school.secondary_phone, params['secondary_phone'])
# Check to see that it's in the database as well
schools_in_db = School.objects.filter(name=params['school_name'])
self.assertGreater(len(schools_in_db), 0)
self.assertEqual(schools_in_db[0], school)
示例7: test_create_school
# 需要导入模块: from huxley.accounts.forms.registration import RegistrationForm [as 别名]
# 或者: from huxley.accounts.forms.registration.RegistrationForm import create_school [as 别名]
def test_create_school(self):
""" Tests that the form creates a school object in the DB properly """
# Test that American schools are created properly
params = self.valid_params.copy()
params["SchoolName"] = "GirlsGeneration"
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertFalse(school is None)
self.assertEqual(school.name, params["SchoolName"])
self.assertEqual(school.address, params["SchoolAddress"])
self.assertEqual(school.city, params["SchoolCity"])
self.assertEqual(school.state, params["SchoolState"])
self.assertEqual(school.zip_code, str(params["SchoolZip"]))
self.assertEqual(school.primary_name, params["PrimaryName"])
self.assertEqual(school.primary_email, params["PrimaryEmail"])
self.assertEqual(school.primary_phone, params["PrimaryPhone"])
self.assertEqual(school.program_type, params["program_type"])
self.assertEqual(school.times_attended, params["howmany"])
self.assertEqual(school.min_delegation_size, params["MinDelegation"])
self.assertEqual(school.max_delegation_size, params["MaxDelegation"])
self.assertFalse(school.international)
# Make sure state isn't an empty string, or a string of spaces
# Bit unnecessary though
matches = re.match("^\s*$", school.state)
self.assertTrue(matches is None)
if "SecondaryName" in params:
self.assertEqual(school.secondary_name, params["SecondaryName"])
if "SecondaryEmail" in params:
self.assertEqual(school.secondary_email, params["SecondaryEmail"])
if "SecondaryPhone" in params:
self.assertEqual(school.secondary_phone, params["SecondaryPhone"])
# Check to see that it's in the database as well
schools_in_db = School.objects.filter(name=params["SchoolName"])
self.assertGreater(len(schools_in_db), 0)
self.assertEqual(schools_in_db[0], school)
# Test international school creation
params["SchoolName"] = "GirlsGenerationInternational"
params["SchoolCountry"] = 10
params["us_or_int"] = "international"
form = RegistrationForm(params)
self.assertTrue(form.is_valid())
school = form.create_school()
self.assertFalse(school is None)
self.assertEqual(school.name, params["SchoolName"])
self.assertEqual(school.address, params["SchoolAddress"])
self.assertEqual(school.city, params["SchoolCity"])
self.assertEqual(school.zip_code, str(params["SchoolZip"]))
#self.assertEqual(school.country, params["SchoolCountry"]) TODO
self.assertEqual(school.primary_name, params["PrimaryName"])
self.assertEqual(school.primary_email, params["PrimaryEmail"])
self.assertEqual(school.primary_phone, params["PrimaryPhone"])
self.assertEqual(school.program_type, params["program_type"])
self.assertEqual(school.times_attended, params["howmany"])
self.assertEqual(school.min_delegation_size, params["MinDelegation"])
self.assertEqual(school.max_delegation_size, params["MaxDelegation"])
self.assertTrue(school.international)
if "SchoolState" in params:
self.assertEqual(school.state, params["SchoolState"])
if "SecondaryName" in params:
self.assertEqual(school.secondary_name, params["SecondaryName"])
if "SecondaryEmail" in params:
self.assertEqual(school.secondary_email, params["SecondaryEmail"])
if "SecondaryPhone" in params:
self.assertEqual(school.secondary_phone, params["SecondaryPhone"])
# Check to see that it's in the database as well
schools_in_db = School.objects.filter(name=params["SchoolName"])
self.assertGreater(len(schools_in_db), 0)
self.assertEqual(schools_in_db[0], school)