示例#1
0
 def test_valid_hyperlink(self):
     valid_hyperlink_attachment = AttachmentFactory(
         hyperlink='http://example.com/test_file.txt', content_object=self.simple_object
     )
     valid_hyperlink_attachment.clean()
     self.assertIsNotNone(valid_hyperlink_attachment.hyperlink)
     self.assertEqual(valid_hyperlink_attachment.url, valid_hyperlink_attachment.hyperlink)
示例#2
0
 def test_valid_file(self):
     valid_file_attachment = AttachmentFactory(
         # Note: file content is intended to be a byte-string here.
         file=SimpleUploadedFile('simple_file.txt', b'these are the file contents!'),
         content_object=self.simple_object
     )
     valid_file_attachment.clean()
     self.assertIsNotNone(valid_file_attachment.file)
     self.assertEqual(valid_file_attachment.url, valid_file_attachment.file.url)
示例#3
0
 def test_invalid(self):
     invalid_attachment = AttachmentFactory(
         content_object=self.simple_object)
     with self.assertRaises(ValidationError):
         invalid_attachment.clean()