def test_saves_to_db_by_default(self): password = factory.make_name('password') params = { 'email': '*****@*****.**' % factory.make_string(), 'username': factory.make_name('user'), 'password1': password, 'password2': password, } form = NewUserCreationForm(params) form.save() self.assertIsNotNone(User.objects.get(username=params['username']))
def test_saves_to_db_by_default(self): password = factory.make_name("password") params = { "email": "*****@*****.**" % factory.make_string(), "username": factory.make_name("user"), "password1": password, "password2": password, } form = NewUserCreationForm(params) form.save() self.assertIsNotNone(User.objects.get(username=params["username"]))
def test_saves_to_db_by_default(self): password = factory.make_name('password') params = { 'email': '*****@*****.**' % factory.getRandomString(), 'username': factory.make_name('user'), 'password1': password, 'password2': password, } form = NewUserCreationForm(params) form.save() self.assertIsNotNone(User.objects.get(username=params['username']))
def test_does_not_save_to_db_if_commit_is_False(self): password = factory.make_name('password') params = { 'email': '*****@*****.**' % factory.make_string(), 'username': factory.make_name('user'), 'password1': password, 'password2': password, } form = NewUserCreationForm(params) form.save(commit=False) self.assertItemsEqual([], User.objects.filter(username=params['username']))
def test_does_not_save_to_db_if_commit_is_False(self): password = factory.make_name("password") params = { "email": "*****@*****.**" % factory.make_string(), "username": factory.make_name("user"), "password1": password, "password2": password, } form = NewUserCreationForm(params) form.save(commit=False) self.assertItemsEqual([], User.objects.filter(username=params["username"]))
def test_does_not_save_to_db_if_commit_is_False(self): password = factory.make_name('password') params = { 'email': '*****@*****.**' % factory.getRandomString(), 'username': factory.make_name('user'), 'password1': password, 'password2': password, } form = NewUserCreationForm(params) form.save(commit=False) self.assertItemsEqual( [], User.objects.filter(username=params['username']))
def test_password_not_required_with_external_auth(self): Config.objects.set_config( 'external_auth_url', 'http://auth.example.com') form = NewUserCreationForm() params = { 'email': factory.make_email(), 'username': factory.make_name('user')} form = NewUserCreationForm(params) user = form.save() self.assertFalse(user.has_usable_password())
def test_password_not_required_with_external_auth(self): Config.objects.set_config("external_auth_url", "http://auth.example.com") form = NewUserCreationForm() params = { "email": factory.make_email(), "username": factory.make_name("user"), } form = NewUserCreationForm(params) user = form.save() self.assertFalse(user.has_usable_password())