def test_wrong_email_user_form(self): data = { 'username': self.user1.user.username, 'email': 'wrong@' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = { 'username': self.user1.user.username, 'email': '@test.com' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = { 'username': self.user1.user.username, 'email': 'wrong@test' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = { 'username': self.user1.user.username, 'email': '[email protected]' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = { 'username': self.user1.user.username, 'email': 'wrongtest.com' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_already_used_email_user_form(self): data = { 'username': self.user1.user.username, 'email': self.user2.user.email } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_already_used_email_user_form(self): data = { 'username_new': '', 'email_new': self.user1.user.email } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_valid_change_email_user_form(self): data = { 'username': self.user1.user.username, 'email': '*****@*****.**' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertTrue(form.is_valid())
def test_valid_change_username_user_form(self): data = { 'username': '******', 'email': self.user1.user.email } form = ChangeUserForm(data=data, user=self.user1.user) self.assertTrue(form.is_valid())
def test_forbidden_email_provider_user_form(self): data = { 'username_new': '', 'email_new': '*****@*****.**' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_already_used_username_user_form(self): data = { "username": self.user2.user.username, "email": self.user1.user.email } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_valid_change_email_user_form(self): data = { 'username_new': '', 'email_new': '*****@*****.**' } form = ChangeUserForm(data=data) self.assertTrue(form.is_valid())
def test_valid_change_email_user_form(self): data = { "username": self.user1.user.username, "email": "*****@*****.**" } form = ChangeUserForm(data=data, user=self.user1.user) self.assertTrue(form.is_valid())
def test_forbidden_email_provider_user_form(self): data = { 'username': self.user1.user.username, 'email': '*****@*****.**' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_forbidden_email_provider_user_form(self): moderator = StaffProfileFactory().user if not BannedEmailProvider.objects.filter(provider="yopmail.com").exists(): BannedEmailProvider.objects.create(provider="yopmail.com", moderator=moderator) data = {"username": self.user1.user.username, "email": "*****@*****.**"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_valid_change_pseudo_user_form(self): data = { 'username_new': "MyNewPseudo", 'email_new': '' } form = ChangeUserForm(data=data) self.assertTrue(form.is_valid())
def test_username_slash_changeuser_form(self): ProfileFactory() data = { "username": "******", "email": self.user1.user.email, } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_username_coma_register_form(self): ProfileFactory() data = { 'username': '******', 'email': self.user1.user.email, } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_pseudo_coma_register_form(self): testuser = ProfileFactory() data = { 'username_new': 'Ze,Tester', 'email_new': '' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_username_spaces_register_form(self): # since Django 1.9, models.CharField is striped by default ProfileFactory() data = { 'username': '******', 'email': self.user1.user.email, } form = ChangeUserForm(data=data, user=self.user1.user) self.assertTrue(form.is_valid())
def test_forbidden_email_provider_user_form(self): moderator = StaffProfileFactory().user if not BannedEmailProvider.objects.filter(provider='yopmail.com').exists(): BannedEmailProvider.objects.create(provider='yopmail.com', moderator=moderator) data = { 'username': self.user1.user.username, 'email': '*****@*****.**' } form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_wrong_email_user_form(self): data = {"username_new": "", "email_new": "wrong@"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = {"username_new": "", "email_new": "@test.com"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = {"username_new": "", "email_new": "wrong@test"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = {"username_new": "", "email_new": "[email protected]"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = {"username_new": "", "email_new": "wrongtest.com"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_valid_change_email_user_form(self): data = {"username_new": "", "email_new": "*****@*****.**"} form = ChangeUserForm(data=data) self.assertTrue(form.is_valid())
def test_wrong_email_user_form(self): data = { 'username_new': '', 'email_new': 'wrong@' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = { 'username_new': '', 'email_new': '@test.com' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = { 'username_new': '', 'email_new': 'wrong@test' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = { 'username_new': '', 'email_new': '[email protected]' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid()) data = { 'username_new': '', 'email_new': 'wrongtest.com' } form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_update_profil(self): """Test the profil update (pseudo, email)""" # create dummy user (reference) user_ref = ProfileFactory() login_check = self.client.login( username=user_ref.user.username, password='******') self.assertTrue(login_check) # create dummy user (to test) user = ProfileFactory() login_check = self.client.login( username=user.user.username, password='******') self.assertTrue(login_check) # A. Test email update ---- # A1. If email looks bad form_data = { 'email_new': 'weirdemail@' } form = ChangeUserForm(data=form_data) self.assertFalse(form.is_valid()) # A2. If email is taken form_data = { 'email_new': user_ref.user.email } form = ChangeUserForm(data=form_data) self.assertFalse(form.is_valid()) # A3. If email provider is forbidden form_data = { 'email_new': '*****@*****.**' } form = ChangeUserForm(data=form_data) self.assertFalse(form.is_valid()) # A4. If OK form_data = { 'email_new': '*****@*****.**' } form = ChangeUserForm(data=form_data) self.assertTrue(form.is_valid()) # B. t*Test pseudo update --- # B1. If new pseudo is taken form_data = { 'username_new': user_ref.user.username } form = ChangeUserForm(data=form_data) self.assertFalse(form.is_valid()) # B2. If new pseudo is OK form_data = { 'username_new': 'OriginalPseudo' } form = ChangeUserForm(data=form_data) self.assertTrue(form.is_valid())
def test_valid_change_username_user_form(self): data = {"username": "******", "email": self.user1.user.email} form = ChangeUserForm(data=data, user=self.user1.user) self.assertTrue(form.is_valid())
def test_wrong_email_user_form(self): data = {"username": self.user1.user.username, "email": "wrong@"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = {"username": self.user1.user.username, "email": "@test.com"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = {"username": self.user1.user.username, "email": "wrong@test"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = {"username": self.user1.user.username, "email": "[email protected]"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid()) data = {"username": self.user1.user.username, "email": "wrongtest.com"} form = ChangeUserForm(data=data, user=self.user1.user) self.assertFalse(form.is_valid())
def test_username_spaces_register_form(self): ProfileFactory() data = {'username': '******', 'email': ''} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_valid_change_pseudo_user_form(self): data = {"username_new": "MyNewPseudo", "email_new": ""} form = ChangeUserForm(data=data) self.assertTrue(form.is_valid())
def test_pseudo_coma_register_form(self): testuser = ProfileFactory() data = {"username_new": "Ze,Tester", "email_new": ""} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_forbidden_email_provider_user_form(self): data = {"username_new": "", "email_new": "*****@*****.**"} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())
def test_already_used_email_user_form(self): data = {"username_new": "", "email_new": self.user1.user.email} form = ChangeUserForm(data=data) self.assertFalse(form.is_valid())