Esempio n. 1
0
    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())
Esempio n. 2
0
 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())
Esempio n. 3
0
 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())
Esempio n. 4
0
 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())
Esempio n. 5
0
 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())
Esempio n. 6
0
 def test_forbidden_email_provider_user_form(self):
     data = {
         'username_new': '',
         'email_new': '*****@*****.**'
     }
     form = ChangeUserForm(data=data)
     self.assertFalse(form.is_valid())
Esempio n. 7
0
 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())
Esempio n. 8
0
 def test_valid_change_email_user_form(self):
     data = {
         'username_new': '',
         'email_new': '*****@*****.**'
     }
     form = ChangeUserForm(data=data)
     self.assertTrue(form.is_valid())
Esempio n. 9
0
 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())
Esempio n. 10
0
 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())
Esempio n. 11
0
 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())
Esempio n. 12
0
 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())
Esempio n. 13
0
 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())
Esempio n. 14
0
 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())
Esempio n. 15
0
 def test_valid_change_pseudo_user_form(self):
     data = {
         'username_new': "MyNewPseudo",
         'email_new': ''
     }
     form = ChangeUserForm(data=data)
     self.assertTrue(form.is_valid())
Esempio n. 16
0
 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())
Esempio n. 17
0
 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())
Esempio n. 18
0
 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())
Esempio n. 19
0
 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())
Esempio n. 20
0
 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())
Esempio n. 21
0
 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())
Esempio n. 22
0
 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())
Esempio n. 23
0
    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())
Esempio n. 24
0
 def test_valid_change_email_user_form(self):
     data = {"username_new": "", "email_new": "*****@*****.**"}
     form = ChangeUserForm(data=data)
     self.assertTrue(form.is_valid())
Esempio n. 25
0
    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())
Esempio n. 26
0
 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())
Esempio n. 27
0
 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())
Esempio n. 28
0
    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())
Esempio n. 29
0
    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())
Esempio n. 30
0
 def test_username_spaces_register_form(self):
     ProfileFactory()
     data = {'username': '******', 'email': ''}
     form = ChangeUserForm(data=data)
     self.assertFalse(form.is_valid())
Esempio n. 31
0
 def test_valid_change_pseudo_user_form(self):
     data = {"username_new": "MyNewPseudo", "email_new": ""}
     form = ChangeUserForm(data=data)
     self.assertTrue(form.is_valid())
Esempio n. 32
0
 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())
Esempio n. 33
0
 def test_forbidden_email_provider_user_form(self):
     data = {"username_new": "", "email_new": "*****@*****.**"}
     form = ChangeUserForm(data=data)
     self.assertFalse(form.is_valid())
Esempio n. 34
0
 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())