def test_form_validation_location_policy(self): POLICY['VALIDATION.USER_LOCATION.REQUIRED'] = True try: form = ProfileEditForm({ 'first_name': 'John', 'last_name': 'Doe', 'email': '*****@*****.**' }, instance=self.user) self.assertFalse(form.is_valid()) form = ProfileEditForm({ 'first_name': 'John', 'last_name': 'Doe', 'email': '*****@*****.**', 'street': 'LANE', 'postalcode': 9000, 'city': 'VILLE', 'country': 'DK' }, instance=self.user) self.assertTrue(form.is_valid()) finally: POLICY['VALIDATION.USER_LOCATION.REQUIRED'] = False
def test_form_validation_base(self): # Empty is not allowed form = ProfileEditForm({}, instance=self.user) self.assertFalse(form.is_valid()) # first and last name is required by default form = ProfileEditForm({ 'first_name': 'John', 'last_name': 'Doe', 'email': '*****@*****.**' }, instance=self.user) self.assertTrue(form.is_valid())