mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
83 lines
2.9 KiB
Python
83 lines
2.9 KiB
Python
from zerver.lib.test_classes import ZulipTestCase
|
|
|
|
|
|
class ZcommandTest(ZulipTestCase):
|
|
|
|
def test_invalid_zcommand(self) -> None:
|
|
self.login('hamlet')
|
|
|
|
payload = dict(command="/boil-ocean")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_error(result, "No such command: boil-ocean")
|
|
|
|
payload = dict(command="boil-ocean")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_error(result, "There should be a leading slash in the zcommand.")
|
|
|
|
def test_ping_zcommand(self) -> None:
|
|
self.login('hamlet')
|
|
|
|
payload = dict(command="/ping")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
|
|
def test_night_zcommand(self) -> None:
|
|
self.login('hamlet')
|
|
user = self.example_user('hamlet')
|
|
user.night_mode = False
|
|
user.save()
|
|
|
|
payload = dict(command="/night")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assertIn('Changed to night', result.json()['msg'])
|
|
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assertIn('still in night mode', result.json()['msg'])
|
|
|
|
def test_day_zcommand(self) -> None:
|
|
self.login('hamlet')
|
|
user = self.example_user('hamlet')
|
|
user.night_mode = True
|
|
user.save()
|
|
|
|
payload = dict(command="/day")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assertIn('Changed to day', result.json()['msg'])
|
|
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assertIn('still in day mode', result.json()['msg'])
|
|
|
|
def test_fluid_zcommand(self) -> None:
|
|
self.login("hamlet")
|
|
user = self.example_user("hamlet")
|
|
user.fluid_layout_width = False
|
|
user.save()
|
|
|
|
payload = dict(command="/fluid-width")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assert_in_response('Changed to fluid-width mode!', result)
|
|
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assert_in_response('You are still in fluid width mode', result)
|
|
|
|
def test_fixed_zcommand(self) -> None:
|
|
self.login("hamlet")
|
|
user = self.example_user("hamlet")
|
|
user.fluid_layout_width = True
|
|
user.save()
|
|
|
|
payload = dict(command="/fixed-width")
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assert_in_response('Changed to fixed-width mode!', result)
|
|
|
|
result = self.client_post("/json/zcommand", payload)
|
|
self.assert_json_success(result)
|
|
self.assert_in_response('You are still in fixed width mode', result)
|