コード例 #1
0
 def test_lecturer_email_is_not_none(self):
     lecturer = Lecturer(first_name=self.first_name,
                         last_name=self.first_name,
                         email=None)
     expected_message = "{'email': ['This field cannot be null.']}"
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #2
0
 def test_failure_due_to_long_email_lecturer(self):
     email = 'e' * 151
     lecturer = Lecturer(email=email,
                         first_name=self.first_name,
                         last_name=self.last_name)
     with self.assertRaises(ValidationError):
         lecturer.full_clean()
コード例 #3
0
 def test_successfully_lecturer_creation(self):
     student = Lecturer(first_name=self.first_name,
                        last_name=self.last_name,
                        email=self.email,
                        photo=self.photo
                        )
     student.full_clean()
コード例 #4
0
 def test_failure_due_to_long_last_name_lecturer(self):
     last_name = 'a' * 31
     lecturer = Lecturer(first_name=self.first_name,
                         last_name=last_name,
                         email=self.email)
     with self.assertRaises(ValidationError):
         lecturer.full_clean()
コード例 #5
0
 def test_fail_lecturer_creation(self):
     last_name = 'a' * 101
     lecturer = Lecturer(first_name=self.first_name,
                         last_name=last_name,
                         email=self.email)
     expected_message = "{'last_name': ['Ensure this value has at most 100 characters (it has 101).']}"
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #6
0
ファイル: test_models.py プロジェクト: YaroslavSim/MyFlask
 def test_failure_due_to_long_data_lecturer_email(self):
     """test_failure_due_to_long_data_lecturer_email function."""
     long_email = 'a' * 255
     lecturer = Lecturer(first_name=FIRST_NAME_LECTURER,
                         last_name=LAST_NAME_LECTURER,
                         email=long_email)
     expected_message = 'Ensure this value has at most 254 characters (it has 255).'
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #7
0
ファイル: test_models.py プロジェクト: YaroslavSim/MyFlask
 def test_failure_due_to_long_data_lecturer_name(self):
     """test_failure_due_to_long_data_lecturer_name function."""
     long_data = 'a' * 101
     lecturer = Lecturer(first_name=long_data,
                         last_name=long_data,
                         email=EMAIL_LECTURER)
     expected_message = 'Ensure this value has at most 100 characters (it has 101).'
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #8
0
 def test_failure_due_to_lecturer_long_first_name(self):
     long_first_name = 'a' * 31
     lecturer = Lecturer(first_name=long_first_name,
                         last_name=self.last_name,
                         email=self.email,
                         photo=self.photo
                         )
     expected_message = 'Ensure this value has at most 30 characters (it has 31).'
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #9
0
 def test_failure_due_to_lecturer_long_not_valid_email(self):
     long_email = 'a' * 51
     email = Lecturer(first_name=self.first_name,
                      last_name=self.last_name,
                      email=long_email,
                      photo=self.photo
                      )
     expected_messages = 'Enter a valid email address.'
     with self.assertRaisesMessage(ValidationError, expected_messages):
         email.full_clean()
コード例 #10
0
 def test_failure_due_to_lecturer_long_valid_email(self):
     long_email = f"{'a' * 42}@mail.com"
     email = Lecturer(first_name=self.first_name,
                      last_name=self.last_name,
                      email=long_email,
                      photo=self.photo
                      )
     expected_message = 'Ensure this value has at most 50 characters (it has 51).'
     with self.assertRaisesMessage(ValidationError, expected_message):
         email.full_clean()
コード例 #11
0
 def test_successful_lecturer_creation(self):
     lecturer = Lecturer(first_name=self.first_name,
                         last_name=self.last_name,
                         email=self.email)
     lecturer.full_clean()
コード例 #12
0
 def test_failure_due_to_long_lecturer_email(self):
     mail = f'{"a" * 245}@gmail.com'
     lecturer = Lecturer(first_name=self.first_name, last_name=self.last_name, email=mail)
     expected_message = 'Ensure this value has at most 254 characters (it has 255).'
     with self.assertRaisesMessage(ValidationError, expected_message):
         lecturer.full_clean()
コード例 #13
0
ファイル: test_models.py プロジェクト: YaroslavSim/MyFlask
 def test_successful_lecturer_creation(self):
     """test_successful_lecturer_creation function."""
     lecturer = Lecturer(first_name=FIRST_NAME_LECTURER,
                         last_name=LAST_NAME_LECTURER,
                         email=EMAIL_LECTURER)
     lecturer.full_clean()
コード例 #14
0
 def test_successful_lecturer_creation(self):
     lecturer = Lecturer(first_name="name",
                         last_name="last_name",
                         email='*****@*****.**')
     lecturer.full_clean()