コード例 #1
0
    def test_max_length_on_employee_last_name(self):
        test_employee = Employee(last_name='test',
                                 first_name='test',
                                 job_title='test',
                                 job_description='test',
                                 bio='test',
                                 skills='test')

        test_employee.last_name = 't' * 21

        with self.assertRaises(ValidationError):
            test_employee.full_clean()
            test_employee.save()
コード例 #2
0
    def test_no_empty_strings_in_employee_last_name(self):
        test_employee = Employee(last_name='test',
                                 first_name='test',
                                 job_title='test',
                                 job_description='test',
                                 bio='test',
                                 skills='test')

        test_employee.last_name = ''

        with self.assertRaises(ValidationError):
            test_employee.full_clean()
            test_employee.save()
コード例 #3
0
    def test_employee_last_name_can_be_overwritten(self):
        test_employee = Employee(last_name='test',
                                 first_name='test',
                                 job_title='test',
                                 job_description='test',
                                 bio='test',
                                 skills='test')
        test_employee.full_clean()
        test_employee.save()
        changed_string = "CHANGED"
        expected = changed_string

        test_employee.last_name = changed_string
        test_employee.full_clean
        test_employee.save()
        test_employee_from_db = Employee.objects.get(pk=1)

        self.assertEqual(expected, test_employee_from_db.last_name)