tests: Fix send_message calls in test_upload.py.

This commit is contained in:
Steve Howell 2017-10-28 07:17:29 -07:00 committed by Tim Abbott
parent f2e3e779eb
commit 9c90c40c08
1 changed files with 15 additions and 15 deletions

View File

@ -20,7 +20,7 @@ from zerver.lib.upload import sanitize_name, S3UploadBackend, \
upload_message_image, delete_message_image, LocalUploadBackend, \
ZulipUploadBackend
import zerver.lib.upload
from zerver.models import Attachment, Recipient, get_user, \
from zerver.models import Attachment, get_user, \
get_old_unclaimed_attachments, Message, UserProfile, Stream, Realm, \
RealmDomain, get_realm, get_system_bot
from zerver.lib.actions import (
@ -202,7 +202,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
self.subscribe(self.example_user("hamlet"), "Denmark")
body = "First message ...[zulip.txt](http://localhost:9991" + uri + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
self.assertIn('title="zulip.txt"', self.get_last_message().rendered_content)
def test_file_download_unauthed(self):
@ -269,7 +269,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
# Send message refering only dummy_1
self.subscribe(self.example_user("hamlet"), "Denmark")
body = "Some files here ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
# dummy_2 should not exist in database or the uploads folder
do_delete_old_unclaimed_attachments(2)
@ -280,7 +280,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
# type: () -> None
self.login(self.example_email("hamlet"))
body = "Test message ...[zulip.txt](http://localhost:9991/user_uploads/1/64/fake_path_id.txt)"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
self.assertFalse(Attachment.objects.filter(path_id = "1/64/fake_path_id.txt").exists())
def test_multiple_claim_attachments(self):
@ -297,9 +297,9 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
self.subscribe(self.example_user("hamlet"), "Denmark")
body = "First message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
body = "Second message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
self.assertEqual(Attachment.objects.get(path_id=d1_path_id).messages.count(), 2)
@ -318,25 +318,25 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
# First, send the mesasge to the new private stream.
body = "First message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("hamlet"), "private_stream", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "private_stream", body, "test")
self.assertFalse(Attachment.objects.get(path_id=d1_path_id).is_realm_public)
self.assertEqual(Attachment.objects.get(path_id=d1_path_id).messages.count(), 1)
# Then, try having a user who didn't receive the message try to publish it, and fail
body = "Illegal message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("cordelia"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("cordelia"), "Denmark", body, "test")
self.assertEqual(Attachment.objects.get(path_id=d1_path_id).messages.count(), 1)
self.assertFalse(Attachment.objects.get(path_id=d1_path_id).is_realm_public)
# Then, have the owner PM it to another user, giving that other user access.
body = "Second message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("hamlet"), self.example_email("othello"), Recipient.PERSONAL, body, "test")
self.send_personal_message(self.example_email("hamlet"), self.example_email("othello"), body)
self.assertEqual(Attachment.objects.get(path_id=d1_path_id).messages.count(), 2)
self.assertFalse(Attachment.objects.get(path_id=d1_path_id).is_realm_public)
# Then, have that new recipient user publish it.
body = "Third message ...[zulip.txt](http://localhost:9991/user_uploads/" + d1_path_id + ")"
self.send_message(self.example_email("othello"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("othello"), "Denmark", body, "test")
self.assertEqual(Attachment.objects.get(path_id=d1_path_id).messages.count(), 3)
self.assertTrue(Attachment.objects.get(path_id=d1_path_id).is_realm_public)
@ -359,7 +359,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
self.subscribe(self.example_user("hamlet"), "test")
body = ("[f1.txt](http://localhost:9991/user_uploads/" + f1_path_id + ")"
"[f2.txt](http://localhost:9991/user_uploads/" + f2_path_id + ")")
msg_id = self.send_message(self.example_email("hamlet"), "test", Recipient.STREAM, body, "test")
msg_id = self.send_stream_message(self.example_email("hamlet"), "test", body, "test")
result = self.client_post("/json/user_uploads", {'file': f3})
f3_path_id = re.sub('/user_uploads/', '', result.json()['uri'])
@ -509,7 +509,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
uri = result.json()['uri']
fp_path_id = re.sub('/user_uploads/', '', uri)
body = "First message ...[zulip.txt](http://localhost:9991/user_uploads/" + fp_path_id + ")"
self.send_message(self.example_email("hamlet"), "test-subscribe", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "test-subscribe", body, "test")
self.logout()
# Subscribed user should be able to view file
@ -544,7 +544,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
uri = result.json()['uri']
fp_path_id = re.sub('/user_uploads/', '', uri)
body = "First message ...[zulip.txt](http://localhost:9991/user_uploads/" + fp_path_id + ")"
self.send_message(self.example_email("hamlet"), "test-subscribe", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "test-subscribe", body, "test")
self.logout()
# Now all users should be able to access the files
@ -1012,7 +1012,7 @@ class S3Test(ZulipTestCase):
self.subscribe(self.example_user("hamlet"), "Denmark")
body = "First message ...[zulip.txt](http://localhost:9991" + uri + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
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
@ -1054,7 +1054,7 @@ class S3Test(ZulipTestCase):
self.subscribe(self.example_user("hamlet"), "Denmark")
body = "First message ...[zulip.txt](http://localhost:9991" + uri + ")"
self.send_message(self.example_email("hamlet"), "Denmark", Recipient.STREAM, body, "test")
self.send_stream_message(self.example_email("hamlet"), "Denmark", body, "test")
self.assertIn('title="zulip.txt"', self.get_last_message().rendered_content)
class UploadTitleTests(TestCase):