mirror of https://github.com/zulip/zulip.git
tests: Renamed AuthedTestCase to ZulipTestCase.
This commit is contained in:
parent
29ba10dfdd
commit
fd6ee7117f
|
@ -65,7 +65,7 @@ the regression.
|
|||
|
||||
Another important file to skim is
|
||||
[zerver/lib/test_helpers.py](https://github.com/zulip/zulip/blob/master/zerver/lib/test_helpers.py),
|
||||
which contains test helpers and our `AuthedTestCase` class.
|
||||
which contains test helpers and our `ZulipTestCase` class.
|
||||
|
||||
### Setting up data for tests
|
||||
|
||||
|
@ -78,7 +78,7 @@ The fixture data includes a few users that are named after
|
|||
Shakesepeare characters, and they are part of the "zulip.com" realm.
|
||||
|
||||
Generally, you will also do some explicit data setup of your own. Here
|
||||
are a couple useful methods in AuthedTestCase:
|
||||
are a couple useful methods in ZulipTestCase:
|
||||
|
||||
- common_subscribe_to_streams
|
||||
- send_message
|
||||
|
@ -123,7 +123,7 @@ endpoint test generally follows this pattern:
|
|||
- Check the data that comes back from the endpoint.
|
||||
|
||||
Generally, if you are doing endpoint tests, you will want to create a
|
||||
test class that is a subclass of `AuthedTestCase`, which will provide
|
||||
test class that is a subclass of `ZulipTestCase`, which will provide
|
||||
you helper methods like the following:
|
||||
|
||||
- api_auth
|
||||
|
|
|
@ -270,7 +270,7 @@ def write_instrumentation_reports():
|
|||
print('Untested-url report is in %s' % (fn,))
|
||||
|
||||
|
||||
class AuthedTestCase(TestCase):
|
||||
class ZulipTestCase(TestCase):
|
||||
'''
|
||||
WRAPPER_COMMENT:
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from zerver.lib.actions import do_deactivate_realm, do_deactivate_user, \
|
|||
do_reactivate_realm, do_reactivate_user
|
||||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase
|
||||
ZulipTestCase
|
||||
)
|
||||
from zerver.models import \
|
||||
get_realm, get_user_profile_by_email, email_to_username, UserProfile
|
||||
|
@ -167,7 +167,7 @@ class AuthBackendTest(TestCase):
|
|||
good_kwargs=good_kwargs,
|
||||
bad_kwargs=bad_kwargs)
|
||||
|
||||
class GitHubAuthBackendTest(AuthedTestCase):
|
||||
class GitHubAuthBackendTest(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
self.email = 'hamlet@zulip.com'
|
||||
|
@ -273,7 +273,7 @@ class GitHubAuthBackendTest(AuthedTestCase):
|
|||
self.assert_in_response('Your e-mail does not match any '
|
||||
'existing open organization.', result)
|
||||
|
||||
class FetchAPIKeyTest(AuthedTestCase):
|
||||
class FetchAPIKeyTest(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
self.email = "hamlet@zulip.com"
|
||||
|
@ -317,7 +317,7 @@ class FetchAPIKeyTest(AuthedTestCase):
|
|||
password=initial_password(self.email)))
|
||||
self.assert_json_error_contains(result, "Your realm has been deactivated", 403)
|
||||
|
||||
class DevFetchAPIKeyTest(AuthedTestCase):
|
||||
class DevFetchAPIKeyTest(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
self.email = "hamlet@zulip.com"
|
||||
|
@ -353,7 +353,7 @@ class DevFetchAPIKeyTest(AuthedTestCase):
|
|||
dict(username=self.email))
|
||||
self.assert_json_error_contains(result, "Dev environment not enabled.", 400)
|
||||
|
||||
class DevGetEmailsTest(AuthedTestCase):
|
||||
class DevGetEmailsTest(ZulipTestCase):
|
||||
def test_success(self):
|
||||
# type: () -> None
|
||||
result = self.client_get("/api/v1/dev_get_emails")
|
||||
|
@ -367,7 +367,7 @@ class DevGetEmailsTest(AuthedTestCase):
|
|||
result = self.client_get("/api/v1/dev_get_emails")
|
||||
self.assert_json_error_contains(result, "Dev environment not enabled.", 400)
|
||||
|
||||
class FetchAuthBackends(AuthedTestCase):
|
||||
class FetchAuthBackends(ZulipTestCase):
|
||||
def test_fetch_auth_backend_format(self):
|
||||
# type: () -> None
|
||||
result = self.client_get("/api/v1/get_auth_backends")
|
||||
|
|
|
@ -11,7 +11,7 @@ from zerver.lib.actions import do_deactivate_realm, do_deactivate_user, \
|
|||
do_reactivate_user, do_reactivate_realm
|
||||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase
|
||||
ZulipTestCase
|
||||
)
|
||||
from zerver.lib.request import \
|
||||
REQ, has_request_variables, RequestVariableMissingError, \
|
||||
|
@ -403,7 +403,7 @@ class ValidatorTestCase(TestCase):
|
|||
person = 'misconfigured data'
|
||||
self.assertEqual(check_person(person), 'This is not a valid person')
|
||||
|
||||
class DeactivatedRealmTest(AuthedTestCase):
|
||||
class DeactivatedRealmTest(ZulipTestCase):
|
||||
def test_send_deactivated_realm(self):
|
||||
"""
|
||||
rest_dispatch rejects requests in a deactivated realm, both /json and api
|
||||
|
@ -478,7 +478,7 @@ class DeactivatedRealmTest(AuthedTestCase):
|
|||
content_type="application/json")
|
||||
self.assert_json_error_contains(result, "has been deactivated", status_code=400)
|
||||
|
||||
class LoginRequiredTest(AuthedTestCase):
|
||||
class LoginRequiredTest(ZulipTestCase):
|
||||
def test_login_required(self):
|
||||
"""
|
||||
Verifies the zulip_login_required decorator blocks deactivated users.
|
||||
|
@ -513,7 +513,7 @@ class LoginRequiredTest(AuthedTestCase):
|
|||
result = self.client_get('/accounts/accept_terms/')
|
||||
self.assertEqual(result.status_code, 302)
|
||||
|
||||
class FetchAPIKeyTest(AuthedTestCase):
|
||||
class FetchAPIKeyTest(ZulipTestCase):
|
||||
def test_fetch_api_key_success(self):
|
||||
email = "cordelia@zulip.com"
|
||||
|
||||
|
@ -528,7 +528,7 @@ class FetchAPIKeyTest(AuthedTestCase):
|
|||
result = self.client_post("/json/fetch_api_key", {"password": "wrong_password"})
|
||||
self.assert_json_error_contains(result, "password is incorrect")
|
||||
|
||||
class InactiveUserTest(AuthedTestCase):
|
||||
class InactiveUserTest(ZulipTestCase):
|
||||
def test_send_deactivated_user(self):
|
||||
"""
|
||||
rest_dispatch rejects requests from deactivated users, both /json and api
|
||||
|
@ -609,7 +609,7 @@ class InactiveUserTest(AuthedTestCase):
|
|||
self.assert_json_error_contains(result, "Account not active", status_code=400)
|
||||
|
||||
|
||||
class TestValidateApiKey(AuthedTestCase):
|
||||
class TestValidateApiKey(ZulipTestCase):
|
||||
def setUp(self):
|
||||
self.webhook_bot = get_user_profile_by_email('webhook-bot@zulip.com')
|
||||
self.default_bot = get_user_profile_by_email('default-bot@zulip.com')
|
||||
|
@ -696,7 +696,7 @@ class TestInternalNotifyView(TestCase):
|
|||
self.assertTrue(is_local_addr('::1'))
|
||||
self.assertFalse(is_local_addr('42.43.44.45'))
|
||||
|
||||
class TestAuthenticatedJsonPostViewDecorator(AuthedTestCase):
|
||||
class TestAuthenticatedJsonPostViewDecorator(ZulipTestCase):
|
||||
def test_authenticated_json_post_view_if_everything_is_correct(self):
|
||||
user_email = 'hamlet@zulip.com'
|
||||
self._login(user_email)
|
||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import absolute_import
|
|||
from django.test import TestCase
|
||||
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase,
|
||||
ZulipTestCase,
|
||||
most_recent_message,
|
||||
most_recent_usermessage,
|
||||
)
|
||||
|
@ -44,7 +44,7 @@ from django.conf import settings
|
|||
from typing import Any, Callable, Mapping, Union
|
||||
|
||||
|
||||
class TestStreamEmailMessagesSuccess(AuthedTestCase):
|
||||
class TestStreamEmailMessagesSuccess(ZulipTestCase):
|
||||
def test_receive_stream_email_messages_success(self):
|
||||
|
||||
# build dummy messages for stream
|
||||
|
@ -72,7 +72,7 @@ class TestStreamEmailMessagesSuccess(AuthedTestCase):
|
|||
self.assertEqual(get_display_recipient(message.recipient), stream.name)
|
||||
self.assertEqual(message.topic_name(), incoming_valid_message['Subject'])
|
||||
|
||||
class TestStreamEmailMessagesEmptyBody(AuthedTestCase):
|
||||
class TestStreamEmailMessagesEmptyBody(ZulipTestCase):
|
||||
def test_receive_stream_email_messages_empty_body(self):
|
||||
|
||||
# build dummy messages for stream
|
||||
|
@ -109,7 +109,7 @@ class TestStreamEmailMessagesEmptyBody(AuthedTestCase):
|
|||
exception_message = str(e)
|
||||
self.assertEqual(exception_message, "Unable to find plaintext or HTML message body")
|
||||
|
||||
class TestMissedPersonalMessageEmailMessages(AuthedTestCase):
|
||||
class TestMissedPersonalMessageEmailMessages(ZulipTestCase):
|
||||
def test_receive_missed_personal_message_email_messages(self):
|
||||
|
||||
# build dummy messages for missed messages email reply
|
||||
|
@ -148,7 +148,7 @@ class TestMissedPersonalMessageEmailMessages(AuthedTestCase):
|
|||
self.assertEqual(message.recipient.id, user_profile.id)
|
||||
self.assertEqual(message.recipient.type, Recipient.PERSONAL)
|
||||
|
||||
class TestMissedHuddleMessageEmailMessages(AuthedTestCase):
|
||||
class TestMissedHuddleMessageEmailMessages(ZulipTestCase):
|
||||
def test_receive_missed_huddle_message_email_messages(self):
|
||||
|
||||
# build dummy messages for missed messages email reply
|
||||
|
@ -194,7 +194,7 @@ class TestMissedHuddleMessageEmailMessages(AuthedTestCase):
|
|||
self.assertEqual(message.sender, get_user_profile_by_email("cordelia@zulip.com"))
|
||||
self.assertEqual(message.recipient.type, Recipient.HUDDLE)
|
||||
|
||||
class TestMissedMessageAddressWithEmptyGateway(AuthedTestCase):
|
||||
class TestMissedMessageAddressWithEmptyGateway(ZulipTestCase):
|
||||
def test_address_with_empty_gateway(self):
|
||||
self.login("othello@zulip.com")
|
||||
result = self.client_post("/json/messages", {"type": "private",
|
||||
|
@ -211,7 +211,7 @@ class TestMissedMessageAddressWithEmptyGateway(AuthedTestCase):
|
|||
self.assertEqual(mm_address, settings.NOREPLY_EMAIL_ADDRESS)
|
||||
|
||||
|
||||
class TestDigestEmailMessages(AuthedTestCase):
|
||||
class TestDigestEmailMessages(ZulipTestCase):
|
||||
@mock.patch('zerver.lib.digest.enough_traffic')
|
||||
@mock.patch('zerver.lib.digest.send_future_email')
|
||||
def test_receive_digest_email_messages(self, mock_send_future_email, mock_enough_traffic):
|
||||
|
@ -233,7 +233,7 @@ class TestDigestEmailMessages(AuthedTestCase):
|
|||
self.assertEqual(mock_send_future_email.call_args[0][0][0]['email'],
|
||||
u'othello@zulip.com')
|
||||
|
||||
class TestReplyExtraction(AuthedTestCase):
|
||||
class TestReplyExtraction(ZulipTestCase):
|
||||
def test_reply_is_extracted_from_plain(self):
|
||||
|
||||
# build dummy messages for stream
|
||||
|
|
|
@ -51,7 +51,7 @@ from zerver.lib.actions import (
|
|||
)
|
||||
|
||||
from zerver.lib.event_queue import allocate_client_descriptor
|
||||
from zerver.lib.test_helpers import AuthedTestCase, POSTRequestMock
|
||||
from zerver.lib.test_helpers import ZulipTestCase, POSTRequestMock
|
||||
from zerver.lib.validator import (
|
||||
check_bool, check_dict, check_int, check_list, check_string,
|
||||
equals, check_none_or, Validator
|
||||
|
@ -67,7 +67,7 @@ import ujson
|
|||
from six.moves import range
|
||||
|
||||
|
||||
class GetEventsTest(AuthedTestCase):
|
||||
class GetEventsTest(ZulipTestCase):
|
||||
def tornado_call(self, view_func, user_profile, post_data):
|
||||
# type: (Callable[[HttpRequest, UserProfile], HttpResponse], UserProfile, Dict[str, Any]) -> HttpResponse
|
||||
request = POSTRequestMock(post_data, user_profile)
|
||||
|
@ -204,7 +204,7 @@ class GetEventsTest(AuthedTestCase):
|
|||
self.assertEqual(events[0]["type"], "message")
|
||||
self.assertEqual(events[0]["message"]["display_recipient"], "Denmark")
|
||||
|
||||
class EventsRegisterTest(AuthedTestCase):
|
||||
class EventsRegisterTest(ZulipTestCase):
|
||||
user_profile = get_user_profile_by_email("hamlet@zulip.com")
|
||||
bot = get_user_profile_by_email("welcome-bot@zulip.com")
|
||||
maxDiff = None # type: Optional[int]
|
||||
|
@ -839,7 +839,7 @@ class EventsRegisterTest(AuthedTestCase):
|
|||
error = stream_update_schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
class FetchInitialStateDataTest(AuthedTestCase):
|
||||
class FetchInitialStateDataTest(ZulipTestCase):
|
||||
# Non-admin users don't have access to all bots
|
||||
def test_realm_bots_non_admin(self):
|
||||
# type: () -> None
|
||||
|
|
|
@ -14,7 +14,7 @@ from zerver.lib.rate_limiter import (
|
|||
)
|
||||
|
||||
from zerver.lib.actions import compute_mit_user_fullname
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
from zerver.models import get_user_profile_by_email
|
||||
from zerver.lib.test_runner import slow
|
||||
|
||||
|
@ -53,7 +53,7 @@ class MITNameTest(TestCase):
|
|||
with mock.patch('DNS.dnslookup', return_value=[['POP IMAP.EXCHANGE.MIT.EDU starnine']]):
|
||||
self.assertTrue(not_mit_mailing_list("sipbexch@mit.edu"))
|
||||
|
||||
class RateLimitTests(AuthedTestCase):
|
||||
class RateLimitTests(ZulipTestCase):
|
||||
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
|
@ -127,7 +127,7 @@ class RateLimitTests(AuthedTestCase):
|
|||
|
||||
self.assert_json_success(result)
|
||||
|
||||
class APNSTokenTests(AuthedTestCase):
|
||||
class APNSTokenTests(ZulipTestCase):
|
||||
def test_add_token(self):
|
||||
# type: () -> None
|
||||
email = "cordelia@zulip.com"
|
||||
|
@ -148,7 +148,7 @@ class APNSTokenTests(AuthedTestCase):
|
|||
result = self.client_delete('/json/users/me/apns_device_token', {'token': token})
|
||||
self.assert_json_success(result)
|
||||
|
||||
class GCMTokenTests(AuthedTestCase):
|
||||
class GCMTokenTests(ZulipTestCase):
|
||||
def test_add_token(self):
|
||||
# type: () -> None
|
||||
email = "cordelia@zulip.com"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
from zerver.lib.test_runner import slow
|
||||
from zerver.models import Message, Recipient
|
||||
|
||||
|
@ -8,7 +8,7 @@ from six import text_type
|
|||
from six.moves import urllib
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
class WebhookTestCase(AuthedTestCase):
|
||||
class WebhookTestCase(ZulipTestCase):
|
||||
"""
|
||||
Common for all webhooks tests
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ from django.conf import settings
|
|||
from django.http import HttpResponse
|
||||
from six.moves.http_cookies import SimpleCookie
|
||||
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
from zerver.management.commands import makemessages
|
||||
|
||||
|
||||
class TranslationTestCase(AuthedTestCase):
|
||||
class TranslationTestCase(ZulipTestCase):
|
||||
"""
|
||||
Tranlations strings should change with locale. URLs should be locale
|
||||
aware.
|
||||
|
@ -68,7 +68,7 @@ class TranslationTestCase(AuthedTestCase):
|
|||
self.assert_in_response(word, response)
|
||||
|
||||
|
||||
class JsonTranslationTestCase(AuthedTestCase):
|
||||
class JsonTranslationTestCase(ZulipTestCase):
|
||||
@mock.patch('zerver.lib.request._')
|
||||
def test_json_error(self, mock_gettext):
|
||||
# type: (Any) -> None
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.core.management import call_command
|
|||
from zerver.models import get_realm
|
||||
from confirmation.models import RealmCreationKey, generate_realm_creation_url
|
||||
from datetime import timedelta
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
|
||||
class TestSendWebhookFixtureMessage(TestCase):
|
||||
COMMAND_NAME = 'send_webhook_fixture_message'
|
||||
|
@ -61,7 +61,7 @@ class TestSendWebhookFixtureMessage(TestCase):
|
|||
self.assertTrue(open_mock.called)
|
||||
client.post.assert_called_once_with(self.url, {}, content_type="application/json")
|
||||
|
||||
class TestGenerateRealmCreationLink(AuthedTestCase):
|
||||
class TestGenerateRealmCreationLink(ZulipTestCase):
|
||||
COMMAND_NAME = "generate_realm_creation_link"
|
||||
|
||||
def test_generate_link_and_create_realm(self):
|
||||
|
|
|
@ -10,7 +10,7 @@ from zerver.lib.test_runner import slow
|
|||
from zilencer.models import Deployment
|
||||
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase,
|
||||
ZulipTestCase,
|
||||
get_user_messages,
|
||||
message_ids, message_stream_count,
|
||||
most_recent_message,
|
||||
|
@ -43,7 +43,7 @@ from six import text_type
|
|||
from six.moves import range
|
||||
from typing import Any, Optional
|
||||
|
||||
class TestCrossRealmPMs(AuthedTestCase):
|
||||
class TestCrossRealmPMs(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
settings.CROSS_REALM_BOT_EMAILS.add('test-og-bot@zulip.com')
|
||||
|
@ -177,7 +177,7 @@ class TestCrossRealmPMs(AuthedTestCase):
|
|||
self.send_message(user1_email, [user2_email, user3_email],
|
||||
Recipient.PERSONAL)
|
||||
|
||||
class PersonalMessagesTest(AuthedTestCase):
|
||||
class PersonalMessagesTest(ZulipTestCase):
|
||||
|
||||
def test_auto_subbed_to_personals(self):
|
||||
# type: () -> None
|
||||
|
@ -276,7 +276,7 @@ class PersonalMessagesTest(AuthedTestCase):
|
|||
self.login("hamlet@zulip.com")
|
||||
self.assert_personal("hamlet@zulip.com", "othello@zulip.com", u"hümbüǵ")
|
||||
|
||||
class StreamMessagesTest(AuthedTestCase):
|
||||
class StreamMessagesTest(ZulipTestCase):
|
||||
|
||||
def assert_stream_message(self, stream_name, subject="test subject",
|
||||
content="test content"):
|
||||
|
@ -406,7 +406,7 @@ class StreamMessagesTest(AuthedTestCase):
|
|||
self.assert_stream_message(non_ascii_stream_name, subject=u"hümbüǵ",
|
||||
content=u"hümbüǵ")
|
||||
|
||||
class MessageDictTest(AuthedTestCase):
|
||||
class MessageDictTest(ZulipTestCase):
|
||||
@slow('builds lots of messages')
|
||||
def test_bulk_message_fetching(self):
|
||||
# type: () -> None
|
||||
|
@ -477,7 +477,7 @@ class MessageDictTest(AuthedTestCase):
|
|||
self.assertEqual(message.rendered_content, expected_content)
|
||||
self.assertEqual(message.rendered_content_version, bugdown.version)
|
||||
|
||||
class MessagePOSTTest(AuthedTestCase):
|
||||
class MessagePOSTTest(ZulipTestCase):
|
||||
|
||||
def test_message_to_self(self):
|
||||
# type: () -> None
|
||||
|
@ -766,7 +766,7 @@ class MessagePOSTTest(AuthedTestCase):
|
|||
user.realm.domain = domain
|
||||
user.realm.save()
|
||||
|
||||
class EditMessageTest(AuthedTestCase):
|
||||
class EditMessageTest(ZulipTestCase):
|
||||
def check_message(self, msg_id, subject=None, content=None):
|
||||
# type: (int, Optional[text_type], Optional[text_type]) -> Message
|
||||
msg = Message.objects.get(id=msg_id)
|
||||
|
@ -1136,7 +1136,7 @@ class MirroredMessageUsersTest(TestCase):
|
|||
bob = get_user_profile_by_email('bob@zulip.com')
|
||||
self.assertTrue(bob.is_mirror_dummy)
|
||||
|
||||
class StarTests(AuthedTestCase):
|
||||
class StarTests(ZulipTestCase):
|
||||
|
||||
def change_star(self, messages, add=True):
|
||||
# type: (List[int], bool) -> HttpResponse
|
||||
|
@ -1190,7 +1190,7 @@ class StarTests(AuthedTestCase):
|
|||
self.assertEqual(sent_message.message.content, content)
|
||||
self.assertFalse(sent_message.flags.starred)
|
||||
|
||||
class AttachmentTest(AuthedTestCase):
|
||||
class AttachmentTest(ZulipTestCase):
|
||||
def test_basics(self):
|
||||
# type: () -> None
|
||||
self.assertFalse(Message.content_has_attachment('whatever'))
|
||||
|
@ -1244,7 +1244,7 @@ class AttachmentTest(AuthedTestCase):
|
|||
attachment = Attachment.objects.get(path_id=path_id)
|
||||
self.assertTrue(attachment.is_claimed())
|
||||
|
||||
class LogDictTest(AuthedTestCase):
|
||||
class LogDictTest(ZulipTestCase):
|
||||
def test_to_log_dict(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
|
@ -1273,7 +1273,7 @@ class LogDictTest(AuthedTestCase):
|
|||
self.assertEqual(dct['subject'], 'Copenhagen')
|
||||
self.assertEqual(dct['type'], 'stream')
|
||||
|
||||
class CheckMessageTest(AuthedTestCase):
|
||||
class CheckMessageTest(ZulipTestCase):
|
||||
def test_basic_check_message_call(self):
|
||||
# type: () -> None
|
||||
sender = get_user_profile_by_email('othello@zulip.com')
|
||||
|
|
|
@ -15,7 +15,7 @@ from zerver.lib.narrow import (
|
|||
)
|
||||
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase, POSTRequestMock,
|
||||
ZulipTestCase, POSTRequestMock,
|
||||
TestCase,
|
||||
get_user_messages, message_ids, queries_captured,
|
||||
)
|
||||
|
@ -50,7 +50,7 @@ def mute_stream(realm, user_profile, stream_name):
|
|||
subscription.in_home_view = False
|
||||
subscription.save()
|
||||
|
||||
class NarrowBuilderTest(AuthedTestCase):
|
||||
class NarrowBuilderTest(ZulipTestCase):
|
||||
def setUp(self):
|
||||
self.realm = get_realm('zulip.com')
|
||||
self.user_profile = get_user_profile_by_email("hamlet@zulip.com")
|
||||
|
@ -254,7 +254,7 @@ class BuildNarrowFilterTest(TestCase):
|
|||
for e in reject_events:
|
||||
self.assertFalse(narrow_filter(e))
|
||||
|
||||
class IncludeHistoryTest(AuthedTestCase):
|
||||
class IncludeHistoryTest(ZulipTestCase):
|
||||
def test_ok_to_include_history(self):
|
||||
realm = get_realm('zulip.com')
|
||||
create_stream_if_needed(realm, 'public_stream')
|
||||
|
@ -298,7 +298,7 @@ class IncludeHistoryTest(AuthedTestCase):
|
|||
]
|
||||
self.assertTrue(ok_to_include_history(narrow, realm))
|
||||
|
||||
class GetOldMessagesTest(AuthedTestCase):
|
||||
class GetOldMessagesTest(ZulipTestCase):
|
||||
|
||||
def get_and_check_messages(self, modified_params):
|
||||
post_params = {"anchor": 1, "num_before": 1, "num_after": 1}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from zerver.lib.actions import get_realm, check_add_realm_emoji
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
import ujson
|
||||
|
||||
class RealmEmojiTest(AuthedTestCase):
|
||||
class RealmEmojiTest(ZulipTestCase):
|
||||
|
||||
def test_list(self):
|
||||
# type: () -> None
|
||||
|
|
|
@ -21,7 +21,7 @@ from zerver.lib.actions import (
|
|||
from zerver.lib.actions import do_set_realm_default_language
|
||||
from zerver.lib.digest import send_digest_email
|
||||
from zerver.lib.notifications import enqueue_welcome_emails, one_click_unsubscribe_link
|
||||
from zerver.lib.test_helpers import AuthedTestCase, find_key_by_email, queries_captured
|
||||
from zerver.lib.test_helpers import ZulipTestCase, find_key_by_email, queries_captured
|
||||
from zerver.lib.test_runner import slow
|
||||
from zerver.lib.session_user import get_session_dict_user
|
||||
|
||||
|
@ -33,7 +33,7 @@ from six.moves import range
|
|||
import six
|
||||
from six import text_type
|
||||
|
||||
class PublicURLTest(AuthedTestCase):
|
||||
class PublicURLTest(ZulipTestCase):
|
||||
"""
|
||||
Account creation URLs are accessible even when not logged in. Authenticated
|
||||
URLs redirect to a page.
|
||||
|
@ -112,7 +112,7 @@ class PublicURLTest(AuthedTestCase):
|
|||
self.assertEqual('success', data['result'])
|
||||
self.assertEqual('ABCD', data['google_client_id'])
|
||||
|
||||
class LoginTest(AuthedTestCase):
|
||||
class LoginTest(ZulipTestCase):
|
||||
"""
|
||||
Logging in, registration, and logging out.
|
||||
"""
|
||||
|
@ -273,7 +273,7 @@ class LoginTest(AuthedTestCase):
|
|||
|
||||
# After this we start manipulating browser information, so stop here.
|
||||
|
||||
class InviteUserTest(AuthedTestCase):
|
||||
class InviteUserTest(ZulipTestCase):
|
||||
|
||||
def invite(self, users, streams):
|
||||
# type: (str, List[text_type]) -> HttpResponse
|
||||
|
@ -542,7 +542,7 @@ class InviteeEmailsParserTests(TestCase):
|
|||
self.assertEqual(get_invitee_emails_set(emails_raw), expected_set)
|
||||
|
||||
|
||||
class EmailUnsubscribeTests(AuthedTestCase):
|
||||
class EmailUnsubscribeTests(ZulipTestCase):
|
||||
def test_missedmessage_unsubscribe(self):
|
||||
# type: () -> None
|
||||
"""
|
||||
|
@ -616,7 +616,7 @@ class EmailUnsubscribeTests(AuthedTestCase):
|
|||
self.assertEqual(0, len(ScheduledJob.objects.filter(
|
||||
type=ScheduledJob.EMAIL, filter_string__iexact=email)))
|
||||
|
||||
class RealmCreationTest(AuthedTestCase):
|
||||
class RealmCreationTest(ZulipTestCase):
|
||||
|
||||
def test_create_realm(self):
|
||||
# type: () -> None
|
||||
|
@ -666,7 +666,7 @@ class RealmCreationTest(AuthedTestCase):
|
|||
result = self.client_get(result["Location"])
|
||||
self.assert_in_response("You're the first one here!", result)
|
||||
|
||||
class UserSignUpTest(AuthedTestCase):
|
||||
class UserSignUpTest(ZulipTestCase):
|
||||
|
||||
def test_user_default_language(self):
|
||||
"""
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any, Dict, List, Mapping, Optional, Sequence
|
|||
from zerver.lib import cache
|
||||
|
||||
from zerver.lib.test_helpers import (
|
||||
AuthedTestCase, queries_captured, tornado_redirected_to_list
|
||||
ZulipTestCase, queries_captured, tornado_redirected_to_list
|
||||
)
|
||||
|
||||
from zerver.decorator import (
|
||||
|
@ -39,7 +39,7 @@ from six import text_type
|
|||
from six.moves import range, urllib
|
||||
|
||||
|
||||
class StreamAdminTest(AuthedTestCase):
|
||||
class StreamAdminTest(ZulipTestCase):
|
||||
def test_make_stream_public(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
|
@ -473,7 +473,7 @@ class StreamAdminTest(AuthedTestCase):
|
|||
"User not authorized to execute queries on behalf of 'baduser@zulip.com'",
|
||||
status_code=403)
|
||||
|
||||
class DefaultStreamTest(AuthedTestCase):
|
||||
class DefaultStreamTest(ZulipTestCase):
|
||||
def get_default_stream_names(self, realm):
|
||||
# type: (Realm) -> Set[text_type]
|
||||
streams = get_default_streams_for_realm(realm)
|
||||
|
@ -534,7 +534,7 @@ class DefaultStreamTest(AuthedTestCase):
|
|||
self.assert_json_success(result)
|
||||
self.assertFalse(stream_name in self.get_default_stream_names(user_profile.realm))
|
||||
|
||||
class SubscriptionPropertiesTest(AuthedTestCase):
|
||||
class SubscriptionPropertiesTest(ZulipTestCase):
|
||||
def test_set_stream_color(self):
|
||||
# type: () -> None
|
||||
"""
|
||||
|
@ -729,7 +729,7 @@ class SubscriptionPropertiesTest(AuthedTestCase):
|
|||
self.assert_json_error(result,
|
||||
"Unknown subscription property: bad")
|
||||
|
||||
class SubscriptionRestApiTest(AuthedTestCase):
|
||||
class SubscriptionRestApiTest(ZulipTestCase):
|
||||
def test_basic_add_delete(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
|
@ -863,7 +863,7 @@ class SubscriptionRestApiTest(AuthedTestCase):
|
|||
self.assert_json_error(result,
|
||||
"Stream name (%s) too long." % (long_stream_name,))
|
||||
|
||||
class SubscriptionAPITest(AuthedTestCase):
|
||||
class SubscriptionAPITest(ZulipTestCase):
|
||||
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
|
@ -1549,7 +1549,7 @@ class SubscriptionAPITest(AuthedTestCase):
|
|||
self.assertFalse(subscription.audible_notifications)
|
||||
|
||||
|
||||
class GetPublicStreamsTest(AuthedTestCase):
|
||||
class GetPublicStreamsTest(ZulipTestCase):
|
||||
|
||||
def test_public_streams(self):
|
||||
# type: () -> None
|
||||
|
@ -1609,7 +1609,7 @@ class GetPublicStreamsTest(AuthedTestCase):
|
|||
**self.api_auth(email))
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
||||
class InviteOnlyStreamTest(AuthedTestCase):
|
||||
class InviteOnlyStreamTest(ZulipTestCase):
|
||||
def test_must_be_subbed_to_send(self):
|
||||
# type: () -> None
|
||||
"""
|
||||
|
@ -1700,7 +1700,7 @@ class InviteOnlyStreamTest(AuthedTestCase):
|
|||
self.assertTrue('othello@zulip.com' in json['subscribers'])
|
||||
self.assertTrue('hamlet@zulip.com' in json['subscribers'])
|
||||
|
||||
class GetSubscribersTest(AuthedTestCase):
|
||||
class GetSubscribersTest(ZulipTestCase):
|
||||
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.template import Template, Context
|
|||
from django.template.loader import get_template
|
||||
|
||||
from zerver.models import get_user_profile_by_email
|
||||
from zerver.lib.test_helpers import get_all_templates, AuthedTestCase
|
||||
from zerver.lib.test_helpers import get_all_templates, ZulipTestCase
|
||||
|
||||
class get_form_value(object):
|
||||
def __init__(self, value):
|
||||
|
@ -26,7 +26,7 @@ class DummyForm(dict):
|
|||
pass
|
||||
|
||||
|
||||
class TemplateTestCase(AuthedTestCase):
|
||||
class TemplateTestCase(ZulipTestCase):
|
||||
"""
|
||||
Tests that backend template rendering doesn't crash.
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ from zerver.models import (
|
|||
get_user_profile_by_email, Recipient, UserMessage
|
||||
)
|
||||
|
||||
from zerver.lib.test_helpers import AuthedTestCase, tornado_redirected_to_list
|
||||
from zerver.lib.test_helpers import ZulipTestCase, tornado_redirected_to_list
|
||||
import ujson
|
||||
|
||||
class PointerTest(AuthedTestCase):
|
||||
class PointerTest(ZulipTestCase):
|
||||
|
||||
def test_update_pointer(self):
|
||||
# type: () -> None
|
||||
|
@ -74,7 +74,7 @@ class PointerTest(AuthedTestCase):
|
|||
self.assert_json_error(result, "Bad value for 'pointer': -2")
|
||||
self.assertEqual(get_user_profile_by_email("hamlet@zulip.com").pointer, -1)
|
||||
|
||||
class UnreadCountTests(AuthedTestCase):
|
||||
class UnreadCountTests(ZulipTestCase):
|
||||
def setUp(self):
|
||||
# type: () -> None
|
||||
self.unread_msg_ids = [self.send_message(
|
||||
|
|
|
@ -6,7 +6,7 @@ from unittest import skip
|
|||
|
||||
from zerver.lib.avatar import avatar_url
|
||||
from zerver.lib.bugdown import url_filename
|
||||
from zerver.lib.test_helpers import AuthedTestCase
|
||||
from zerver.lib.test_helpers import ZulipTestCase
|
||||
from zerver.lib.test_runner import slow
|
||||
from zerver.lib.upload import sanitize_name, S3UploadBackend, \
|
||||
upload_message_image, delete_message_image, LocalUploadBackend
|
||||
|
@ -39,7 +39,7 @@ def destroy_uploads():
|
|||
if os.path.exists(settings.LOCAL_UPLOADS_DIR):
|
||||
shutil.rmtree(settings.LOCAL_UPLOADS_DIR)
|
||||
|
||||
class FileUploadTest(AuthedTestCase):
|
||||
class FileUploadTest(ZulipTestCase):
|
||||
|
||||
def test_rest_endpoint(self):
|
||||
# type: () -> None
|
||||
|
@ -256,7 +256,7 @@ class FileUploadTest(AuthedTestCase):
|
|||
# type: () -> None
|
||||
destroy_uploads()
|
||||
|
||||
class AvatarTest(AuthedTestCase):
|
||||
class AvatarTest(ZulipTestCase):
|
||||
|
||||
def test_multiple_upload_failure(self):
|
||||
# type: () -> None
|
||||
|
@ -381,7 +381,7 @@ class AvatarTest(AuthedTestCase):
|
|||
# type: () -> None
|
||||
destroy_uploads()
|
||||
|
||||
class LocalStorageTest(AuthedTestCase):
|
||||
class LocalStorageTest(ZulipTestCase):
|
||||
|
||||
def test_file_upload_local(self):
|
||||
# type: () -> None
|
||||
|
@ -422,7 +422,7 @@ def use_s3_backend(method):
|
|||
zerver.lib.upload.upload_backend = LocalUploadBackend()
|
||||
return new_method
|
||||
|
||||
class S3Test(AuthedTestCase):
|
||||
class S3Test(ZulipTestCase):
|
||||
|
||||
@use_s3_backend
|
||||
def test_file_upload_s3(self):
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.test import TestCase
|
|||
|
||||
from zerver.lib.test_helpers import (
|
||||
queries_captured, simulated_empty_cache,
|
||||
simulated_queue_client, tornado_redirected_to_list, AuthedTestCase,
|
||||
simulated_queue_client, tornado_redirected_to_list, ZulipTestCase,
|
||||
most_recent_usermessage, most_recent_message,
|
||||
)
|
||||
from zerver.lib.test_runner import slow
|
||||
|
@ -92,7 +92,7 @@ class SlowQueryTest(TestCase):
|
|||
self.assertFalse(is_slow_query(9, '/accounts/webathena_kerberos_login/'))
|
||||
self.assertTrue(is_slow_query(11, '/accounts/webathena_kerberos_login/'))
|
||||
|
||||
class RealmTest(AuthedTestCase):
|
||||
class RealmTest(ZulipTestCase):
|
||||
def assert_user_profile_cache_gets_new_name(self, email, new_realm_name):
|
||||
# type: (text_type, text_type) -> None
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
|
@ -201,7 +201,7 @@ class RealmTest(AuthedTestCase):
|
|||
self.assertNotEqual(realm.default_language, invalid_lang)
|
||||
|
||||
|
||||
class PermissionTest(AuthedTestCase):
|
||||
class PermissionTest(ZulipTestCase):
|
||||
def test_get_admin_users(self):
|
||||
# type: () -> None
|
||||
user_profile = get_user_profile_by_email('hamlet@zulip.com')
|
||||
|
@ -268,7 +268,7 @@ class PermissionTest(AuthedTestCase):
|
|||
result = self.client_patch('/json/users/hamlet@zulip.com', req)
|
||||
self.assert_json_error(result, 'Insufficient permission')
|
||||
|
||||
class AdminCreateUserTest(AuthedTestCase):
|
||||
class AdminCreateUserTest(ZulipTestCase):
|
||||
def test_create_user_backend(self):
|
||||
# type: () -> None
|
||||
|
||||
|
@ -454,7 +454,7 @@ class WorkerTest(TestCase):
|
|||
worker = TestWorker()
|
||||
worker.consume({})
|
||||
|
||||
class ActivityTest(AuthedTestCase):
|
||||
class ActivityTest(ZulipTestCase):
|
||||
def test_activity(self):
|
||||
# type: () -> None
|
||||
self.login("hamlet@zulip.com")
|
||||
|
@ -475,7 +475,7 @@ class ActivityTest(AuthedTestCase):
|
|||
|
||||
self.assert_length(queries, 13)
|
||||
|
||||
class DocPageTest(AuthedTestCase):
|
||||
class DocPageTest(ZulipTestCase):
|
||||
def _test(self, url, expected_content):
|
||||
# type: (str, str) -> None
|
||||
result = self.client_get(url)
|
||||
|
@ -517,7 +517,7 @@ class UserProfileTest(TestCase):
|
|||
self.assertEqual(dct[hamlet.id], 'hamlet@zulip.com')
|
||||
self.assertEqual(dct[othello.id], 'othello@zulip.com')
|
||||
|
||||
class UserChangesTest(AuthedTestCase):
|
||||
class UserChangesTest(ZulipTestCase):
|
||||
def test_update_api_key(self):
|
||||
# type: () -> None
|
||||
email = "hamlet@zulip.com"
|
||||
|
@ -531,7 +531,7 @@ class UserChangesTest(AuthedTestCase):
|
|||
user = get_user_profile_by_email(email)
|
||||
self.assertEqual(new_api_key, user.api_key)
|
||||
|
||||
class ActivateTest(AuthedTestCase):
|
||||
class ActivateTest(ZulipTestCase):
|
||||
def test_basics(self):
|
||||
# type: () -> None
|
||||
user = get_user_profile_by_email('hamlet@zulip.com')
|
||||
|
@ -591,7 +591,7 @@ class ActivateTest(AuthedTestCase):
|
|||
result = self.client_post('/json/users/hamlet@zulip.com/reactivate')
|
||||
self.assert_json_error(result, 'Insufficient permission')
|
||||
|
||||
class BotTest(AuthedTestCase):
|
||||
class BotTest(ZulipTestCase):
|
||||
def assert_num_bots_equal(self, count):
|
||||
# type: (int) -> None
|
||||
result = self.client_get("/json/bots")
|
||||
|
@ -1306,7 +1306,7 @@ class BotTest(AuthedTestCase):
|
|||
self.assert_json_error(result, 'No such user')
|
||||
self.assert_num_bots_equal(1)
|
||||
|
||||
class ChangeSettingsTest(AuthedTestCase):
|
||||
class ChangeSettingsTest(ZulipTestCase):
|
||||
|
||||
def check_well_formed_change_settings_response(self, result):
|
||||
# type: (Dict[str, Any]) -> None
|
||||
|
@ -1451,7 +1451,7 @@ class ChangeSettingsTest(AuthedTestCase):
|
|||
user_profile = get_user_profile_by_email(email)
|
||||
self.assertNotEqual(user_profile.default_language, invalid_lang)
|
||||
|
||||
class GetProfileTest(AuthedTestCase):
|
||||
class GetProfileTest(ZulipTestCase):
|
||||
|
||||
def common_update_pointer(self, email, pointer):
|
||||
# type: (text_type, int) -> None
|
||||
|
@ -1532,7 +1532,7 @@ class GetProfileTest(AuthedTestCase):
|
|||
get_avatar_url(user_profile.avatar_source, user_profile.email),
|
||||
)
|
||||
|
||||
class UserPresenceTests(AuthedTestCase):
|
||||
class UserPresenceTests(ZulipTestCase):
|
||||
def test_get_empty(self):
|
||||
# type: () -> None
|
||||
self.login("hamlet@zulip.com")
|
||||
|
@ -1630,7 +1630,7 @@ class UserPresenceTests(AuthedTestCase):
|
|||
for email in json['presences'].keys():
|
||||
self.assertEqual(split_email_to_domain(email), 'zulip.com')
|
||||
|
||||
class AlertWordTests(AuthedTestCase):
|
||||
class AlertWordTests(ZulipTestCase):
|
||||
interesting_alert_word_list = ['alert', 'multi-word word', u'☃']
|
||||
|
||||
def test_internal_endpoint(self):
|
||||
|
@ -1809,7 +1809,7 @@ class AlertWordTests(AuthedTestCase):
|
|||
self.assertFalse(self.message_does_alert(user_profile_hamlet, "Don't alert on http://t.co/one/ urls"))
|
||||
self.assertFalse(self.message_does_alert(user_profile_hamlet, "Don't alert on http://t.co/one urls"))
|
||||
|
||||
class HomeTest(AuthedTestCase):
|
||||
class HomeTest(ZulipTestCase):
|
||||
@slow('big method')
|
||||
def test_home(self):
|
||||
# type: () -> None
|
||||
|
@ -1942,7 +1942,7 @@ class HomeTest(AuthedTestCase):
|
|||
# TODO: Inspect the page_params data further.
|
||||
# print(ujson.dumps(page_params, indent=2))
|
||||
|
||||
class MutedTopicsTests(AuthedTestCase):
|
||||
class MutedTopicsTests(ZulipTestCase):
|
||||
def test_json_set(self):
|
||||
# type: () -> None
|
||||
email = 'hamlet@zulip.com'
|
||||
|
@ -1989,7 +1989,7 @@ class ExtractedRecipientsTest(TestCase):
|
|||
self.assertEqual(sorted(extract_recipients(s)), ['alice@zulip.com', 'bob@zulip.com'])
|
||||
|
||||
|
||||
class TestMissedMessages(AuthedTestCase):
|
||||
class TestMissedMessages(ZulipTestCase):
|
||||
def normalize_string(self, s):
|
||||
# type: (text_type) -> text_type
|
||||
s = s.strip()
|
||||
|
@ -2088,7 +2088,7 @@ class TestMissedMessages(AuthedTestCase):
|
|||
|
||||
self.assertIn(body, self.normalize_string(msg.body))
|
||||
|
||||
class TestOpenRealms(AuthedTestCase):
|
||||
class TestOpenRealms(ZulipTestCase):
|
||||
def test_open_realm_logic(self):
|
||||
# type: () -> None
|
||||
mit_realm = get_realm("mit.edu")
|
||||
|
|
Loading…
Reference in New Issue