예제 #1
0
    def is_pdf(self):
        """Checks if the file provided is a pdf"""
        default_message = '{} is not a valid pdf'.format(self.display_name)

        if self.data and not CommonValidator.is_pdf(self.data.content_type):
            self.validation_error_builder.add_error(self, default_message,
                                                    self.allow_multiple)

        return self
예제 #2
0
    def test_is_pdf_with_text(self):
        result = CommonValidator.is_pdf(MIME_TYPE['text'])

        self.assertFalse(result)
예제 #3
0
    def test_is_pdf_with_pdf(self):
        result = CommonValidator.is_pdf(MIME_TYPE['pdf'])

        self.assertTrue(result)