zerver/tests: Test S3 file upload with undefined content type.

This commit is contained in:
RobbieClarken 2018-05-14 14:46:59 -04:00 committed by Tim Abbott
parent b9fff04f39
commit efc63d4ca0
1 changed files with 13 additions and 0 deletions

View File

@ -1072,6 +1072,19 @@ class S3Test(ZulipTestCase):
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
self.assertIn('title="dummy.txt"', self.get_last_message().rendered_content)
@use_s3_backend
def test_file_upload_s3_with_undefined_content_type(self) -> None:
conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)
bucket = conn.create_bucket(settings.S3_AUTH_UPLOADS_BUCKET)
user_profile = self.example_user('hamlet')
uri = upload_message_file(u'dummy.txt', len(b'zulip!'), None, b'zulip!', user_profile)
path_id = re.sub('/user_uploads/', '', uri)
self.assertEqual(b"zulip!", bucket.get_key(path_id).get_contents_as_string())
uploaded_file = Attachment.objects.get(owner=user_profile, path_id=path_id)
self.assertEqual(len(b"zulip!"), uploaded_file.size)
@use_s3_backend
def test_message_image_delete_s3(self) -> None:
conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)