You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_custom_user_model.py 916B

12345678910111213141516171819202122232425
  1. from django.test import TestCase
  2. from oscar.apps.customer.forms import ProfileForm
  3. from oscar.core.compat import get_user_model, existing_user_fields
  4. class TestACustomUserModel(TestCase):
  5. def setUp(self):
  6. self.user_klass = get_user_model()
  7. def test_can_be_created_without_error(self):
  8. try:
  9. self.user_klass.objects.create_user('_', 'a@a.com', 'pa55w0rd')
  10. except Exception as e:
  11. self.fail("Unable to create user model: %s" % e)
  12. def test_extra_field_is_accessible(self):
  13. self.assertTrue('extra_field' in existing_user_fields(['extra_field']))
  14. self.assertTrue(hasattr(self.user_klass(), 'extra_field'))
  15. def test_profile_form_doesnt_expose_extra_field(self):
  16. form = ProfileForm(self.user_klass())
  17. expected_fields = set(['first_name', 'last_name', 'email'])
  18. self.assertTrue(expected_fields == set(form.fields))