mirror of https://github.com/zulip/zulip.git
zerver/tests: Test currently_used_upload_space function.
This commit is contained in:
parent
efc63d4ca0
commit
b3a6c0a253
|
@ -21,7 +21,8 @@ from zerver.lib.test_runner import slow
|
||||||
from zerver.lib.upload import sanitize_name, S3UploadBackend, \
|
from zerver.lib.upload import sanitize_name, S3UploadBackend, \
|
||||||
upload_message_file, delete_message_image, LocalUploadBackend, \
|
upload_message_file, delete_message_image, LocalUploadBackend, \
|
||||||
ZulipUploadBackend, MEDIUM_AVATAR_SIZE, resize_avatar, \
|
ZulipUploadBackend, MEDIUM_AVATAR_SIZE, resize_avatar, \
|
||||||
resize_emoji, BadImageError, get_realm_for_filename
|
resize_emoji, BadImageError, get_realm_for_filename, \
|
||||||
|
currently_used_upload_space
|
||||||
import zerver.lib.upload
|
import zerver.lib.upload
|
||||||
from zerver.models import Attachment, get_user, \
|
from zerver.models import Attachment, get_user, \
|
||||||
get_old_unclaimed_attachments, Message, UserProfile, Stream, Realm, \
|
get_old_unclaimed_attachments, Message, UserProfile, Stream, Realm, \
|
||||||
|
@ -1190,3 +1191,20 @@ class SanitizeNameTests(TestCase):
|
||||||
self.assertEqual(sanitize_name(u'snowman☃.txt'), u'snowman.txt')
|
self.assertEqual(sanitize_name(u'snowman☃.txt'), u'snowman.txt')
|
||||||
self.assertEqual(sanitize_name(u'테스트.txt'), u'테스트.txt')
|
self.assertEqual(sanitize_name(u'테스트.txt'), u'테스트.txt')
|
||||||
self.assertEqual(sanitize_name(u'~/."\`\?*"u0`000ssh/test.t**{}ar.gz'), u'.u0000sshtest.tar.gz')
|
self.assertEqual(sanitize_name(u'~/."\`\?*"u0`000ssh/test.t**{}ar.gz'), u'.u0000sshtest.tar.gz')
|
||||||
|
|
||||||
|
|
||||||
|
class UploadSpaceTests(UploadSerializeMixin, ZulipTestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.realm = get_realm("zulip")
|
||||||
|
self.user_profile = self.example_user('hamlet')
|
||||||
|
|
||||||
|
def test_currently_used_upload_space(self) -> None:
|
||||||
|
self.assertEqual(0, currently_used_upload_space(self.realm))
|
||||||
|
|
||||||
|
data = b'zulip!'
|
||||||
|
upload_message_file(u'dummy.txt', len(data), u'text/plain', data, self.user_profile)
|
||||||
|
self.assertEqual(len(data), currently_used_upload_space(self.realm))
|
||||||
|
|
||||||
|
data2 = b'more-data!'
|
||||||
|
upload_message_file(u'dummy2.txt', len(data2), u'text/plain', data2, self.user_profile)
|
||||||
|
self.assertEqual(len(data) + len(data2), currently_used_upload_space(self.realm))
|
||||||
|
|
Loading…
Reference in New Issue