示例#1
0
    def test_title_is_mandatory(self):

        document = Document(description='test_description',
                            body='test_body',
                            user=self.test_user)
        with self.assertRaises(ValidationError):
            document.full_clean()
示例#2
0
    def test_body_is_not_mandatory(self):

        document = Document(title='test_title',
                            description='test_description',
                            user=self.test_user)
        try:
            document.full_clean()
        except ValidationError:
            self.fail('Document is not correct.')
示例#3
0
    def test_description_max_length(self):
        description_max_length = Document.description.field.max_length
        self.assertEqual(description_max_length, 100)

        description = 'a' * 101
        document = Document(title='test_title',
                            description=description,
                            body='test_body',
                            user=self.test_user)
        with self.assertRaises(ValidationError):
            document.full_clean()
示例#4
0
    def test_title_max_length(self):
        title_max_length = Document.title.field.max_length
        self.assertEqual(title_max_length, 50)

        title = 'a' * 51
        document = Document(title=title,
                            description='test_description',
                            body='test_body',
                            user=self.test_user)
        with self.assertRaises(ValidationError):
            document.full_clean()
示例#5
0
    def test_description_limit_max_length(self):
        description_max_length = Document.description.field.max_length
        self.assertEqual(description_max_length, 100)

        description = 'a' * 100
        document = Document(title='test_title',
                            description=description,
                            body='test_body',
                            user=self.test_user)
        try:
            document.full_clean()
        except ValidationError:
            self.fail('Document is not correct.')
示例#6
0
    def test_title_limit_max_length(self):
        title_max_length = Document.title.field.max_length
        self.assertEqual(title_max_length, 50)

        title = 'a' * 50
        document = Document(title=title,
                            description='test_description',
                            body='test_body',
                            user=self.test_user)
        try:
            document.full_clean()
        except ValidationError:
            self.fail('Document is not correct.')