Files
zulip/zerver/tests/test_legacy_subject.py
Steve Howell 1b16693526 tests: Limit email-based logins.
We now have this API...

If you really just need to log in
and not do anything with the actual
user:

    self.login('hamlet')

If you're gonna use the user in the
rest of the test:

    hamlet = self.example_user('hamlet')
    self.login_user(hamlet)

If you are specifically testing
email/password logins (used only in 4 places):

    self.login_by_email(email, password)

And for failures uses this (used twice):

    self.assert_login_failure(email)
2020-03-11 17:10:22 -07:00

24 lines
714 B
Python

from zerver.lib.test_classes import (
ZulipTestCase,
)
class LegacySubjectTest(ZulipTestCase):
def test_legacy_subject(self) -> None:
self.login('hamlet')
payload = dict(
type='stream',
to='Verona',
client='test suite',
content='Test message',
)
payload['subject'] = 'whatever'
result = self.client_post("/json/messages", payload)
self.assert_json_success(result)
# You can't use both subject and topic.
payload['topic'] = 'whatever'
result = self.client_post("/json/messages", payload)
self.assert_json_error(result, "Can't decide between 'topic' and 'subject' arguments")