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
def test_is_pdf_with_text(self): result = CommonValidator.is_pdf(MIME_TYPE['text']) self.assertFalse(result)
def test_is_pdf_with_pdf(self): result = CommonValidator.is_pdf(MIME_TYPE['pdf']) self.assertTrue(result)