mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
lint: Clean up E123 PEP-8 rule.
This commit is contained in:
@@ -350,4 +350,4 @@ COUNT_STATS = {
|
||||
'messages_sent_to_stream:is_bot:hour': CountStat(
|
||||
'messages_sent_to_stream:is_bot', zerver_count_message_by_stream, {},
|
||||
(UserProfile, 'is_bot'), CountStat.HOUR, False)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,4 @@ print(client.create_user({
|
||||
'password': options.new_password,
|
||||
'full_name': options.new_full_name,
|
||||
'short_name': options.new_short_name
|
||||
}))
|
||||
}))
|
||||
|
||||
@@ -80,7 +80,7 @@ def send_update(ticket, content):
|
||||
"to": config.STREAM_FOR_NOTIFICATIONS,
|
||||
"content": content,
|
||||
"subject": trac_subject(ticket)
|
||||
})
|
||||
})
|
||||
|
||||
class ZulipPlugin(Component):
|
||||
implements(ITicketChangeListener)
|
||||
|
||||
@@ -288,7 +288,7 @@ class Client(object):
|
||||
client_name=self.client_name,
|
||||
vendor=vendor,
|
||||
vendor_version=vendor_version,
|
||||
)
|
||||
)
|
||||
|
||||
def do_api_query(self, orig_request, url, method="POST", longpolling=False, files=None):
|
||||
# type: (Mapping[str, Any], str, str, bool, List[IO]) -> Dict[str, Any]
|
||||
|
||||
@@ -90,7 +90,7 @@ if options.sharded:
|
||||
("tabbott-nagios-test-12", "d"),
|
||||
("tabbott-nagios-test-11", "e"),
|
||||
("tabbott-nagios-test-9", "f"),
|
||||
]
|
||||
]
|
||||
for (stream, test) in test_streams:
|
||||
if stream == "message":
|
||||
continue
|
||||
@@ -99,7 +99,7 @@ else:
|
||||
test_streams = [
|
||||
("message", "p"),
|
||||
("tabbott-nagios-test", "a"),
|
||||
]
|
||||
]
|
||||
|
||||
def print_status_and_exit(status):
|
||||
# type: (int) -> None
|
||||
@@ -262,7 +262,7 @@ for key, (stream, test) in hzkeys.items():
|
||||
"subject": "test",
|
||||
"content": str(key),
|
||||
"to": stream,
|
||||
})
|
||||
})
|
||||
receive_zephyrs()
|
||||
|
||||
logger.info("Sent Zulip messages!")
|
||||
|
||||
@@ -69,7 +69,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||
"type": "private",
|
||||
"to": "username@example.com",
|
||||
"content": content,
|
||||
}))
|
||||
}))
|
||||
|
||||
def on_pubmsg(self, c, e):
|
||||
# type: (ServerConnection, Event) -> None
|
||||
@@ -87,7 +87,7 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||
"to": stream,
|
||||
"subject": "IRC",
|
||||
"content": content,
|
||||
}))
|
||||
}))
|
||||
|
||||
def on_dccmsg(self, c, e):
|
||||
# type: (ServerConnection, Event) -> None
|
||||
|
||||
@@ -171,7 +171,7 @@ class JabberToZulipBot(ClientXMPP):
|
||||
type = "private",
|
||||
to = recipient,
|
||||
content = msg["body"],
|
||||
)
|
||||
)
|
||||
ret = self.zulipToJabber.client.send_message(zulip_message)
|
||||
if ret.get("result") != "success":
|
||||
logging.error(str(ret))
|
||||
@@ -199,7 +199,7 @@ class JabberToZulipBot(ClientXMPP):
|
||||
subject = subject,
|
||||
to = stream,
|
||||
content = msg["body"],
|
||||
)
|
||||
)
|
||||
ret = self.zulipToJabber.client.send_message(zulip_message)
|
||||
if ret.get("result") != "success":
|
||||
logging.error(str(ret))
|
||||
|
||||
@@ -45,7 +45,7 @@ def send_log_zulip(file_name, count, lines, extra=""):
|
||||
"to": "logs",
|
||||
"subject": "%s on %s" % (file_name, platform.node()),
|
||||
"content": content,
|
||||
})
|
||||
})
|
||||
|
||||
def process_lines(raw_lines, file_name):
|
||||
# type: (List[str], str) -> None
|
||||
|
||||
@@ -85,7 +85,7 @@ def run_message_handler_for_bot(lib_module, quiet, config_file):
|
||||
message=message,
|
||||
client=restricted_client,
|
||||
state_handler=state_handler
|
||||
)
|
||||
)
|
||||
|
||||
signal.signal(signal.SIGINT, exit_gracefully)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ Example Inputs:
|
||||
subject=message['subject'],
|
||||
to=message['display_recipient'],
|
||||
content=letter,
|
||||
))
|
||||
))
|
||||
|
||||
def handle_message(self, message, client, state_handler):
|
||||
words = message['content'].split()
|
||||
|
||||
@@ -296,8 +296,8 @@ texinfo_documents = [
|
||||
from recommonmark.parser import CommonMarkParser
|
||||
|
||||
source_parsers = {
|
||||
'.md': CommonMarkParser,
|
||||
}
|
||||
'.md': CommonMarkParser,
|
||||
}
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
|
||||
@@ -96,7 +96,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
}
|
||||
}
|
||||
|
||||
def report(state, timestamp, msg=None):
|
||||
# type: (str, Any, Optional[str]) -> None
|
||||
@@ -177,7 +177,7 @@ else:
|
||||
"content": msg_to_send,
|
||||
"subject": "time to send",
|
||||
"to": recipient.email,
|
||||
})
|
||||
})
|
||||
|
||||
msg_content = [] # type: List[str]
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
}
|
||||
}
|
||||
|
||||
def report(state, msg):
|
||||
# type: (str, str) -> None
|
||||
|
||||
@@ -19,7 +19,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
}
|
||||
}
|
||||
|
||||
def report(state, num):
|
||||
# type: (str, str) -> None
|
||||
|
||||
@@ -13,7 +13,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
}
|
||||
}
|
||||
|
||||
def report(state, msg):
|
||||
# type: (str, str) -> None
|
||||
|
||||
@@ -20,7 +20,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
} # type: Dict[str, int]
|
||||
} # type: Dict[str, int]
|
||||
|
||||
def report(state, output):
|
||||
# type: (str, str) -> None
|
||||
|
||||
@@ -35,7 +35,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
} # type: Dict[str, int]
|
||||
} # type: Dict[str, int]
|
||||
|
||||
def report(state, short_msg, too_old=None):
|
||||
# type: (str, str, Set[Any]) -> None
|
||||
@@ -45,7 +45,7 @@ def report(state, short_msg, too_old=None):
|
||||
["%16s: %s" % (user.user_profile.email,
|
||||
user.last_visit.strftime("%Y-%m-%d %H:%M %Z")
|
||||
) for user in too_old]
|
||||
)
|
||||
)
|
||||
print("%s: %s%s" % (state, short_msg, too_old_data))
|
||||
|
||||
exit(states[state])
|
||||
|
||||
@@ -20,7 +20,7 @@ states = {
|
||||
"WARNING": 1,
|
||||
"CRITICAL": 2,
|
||||
"UNKNOWN": 3
|
||||
} # type: Dict[str, int]
|
||||
} # type: Dict[str, int]
|
||||
|
||||
def report(state, data, last_check):
|
||||
# type: (str, str, float) -> None
|
||||
|
||||
@@ -87,7 +87,7 @@ def check_pep8(files):
|
||||
# ignored. It either doesn't fit with the style of the project or should
|
||||
# actually be cleaned up.
|
||||
#
|
||||
'E123', 'E126', 'E226', 'E261', 'E302',
|
||||
'E126', 'E226', 'E261', 'E302',
|
||||
'E401', 'E501', 'E702',
|
||||
|
||||
#
|
||||
@@ -227,7 +227,7 @@ def build_custom_checkers(by_lang):
|
||||
'exclude': set(['zerver/lib/bugdown/codehilite.py',
|
||||
'tools/travis/success-http-headers.txt']),
|
||||
'description': 'Fix tab-based whitespace'},
|
||||
] # type: RuleList
|
||||
] # type: RuleList
|
||||
markdown_whitespace_rules = list([rule for rule in whitespace_rules if rule['pattern'] != '\s+$']) + [
|
||||
# Two spaces trailing a line with other content is okay--it's a markdown line break.
|
||||
# This rule finds one space trailing a non-space, three or more trailing spaces, and
|
||||
@@ -284,7 +284,7 @@ def build_custom_checkers(by_lang):
|
||||
'exclude': set(['tools/lint-all']),
|
||||
'description': 'Argument to report_error should be a literal string enclosed '
|
||||
'by i18n.t()'},
|
||||
]) + whitespace_rules
|
||||
]) + whitespace_rules
|
||||
python_rules = cast(RuleList, [
|
||||
{'pattern': '^(?!#)@login_required',
|
||||
'description': '@login_required is unsupported; use @zulip_login_required'},
|
||||
@@ -401,12 +401,12 @@ def build_custom_checkers(by_lang):
|
||||
'scripts/lib/setup_venv.py',
|
||||
'tools/lint-all']),
|
||||
'description': 'Explicit python invocations should not include a version'}
|
||||
]) + whitespace_rules
|
||||
]) + whitespace_rules
|
||||
bash_rules = [
|
||||
{'pattern': '#!.*sh [-xe]',
|
||||
'description': 'Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches'
|
||||
' to set -x|set -e'},
|
||||
] + whitespace_rules[0:1] # type: RuleList
|
||||
] + whitespace_rules[0:1] # type: RuleList
|
||||
css_rules = cast(RuleList, [
|
||||
{'pattern': '^[^:]*:\S[^:]*;$',
|
||||
'description': "Missing whitespace after : in CSS"},
|
||||
@@ -420,7 +420,7 @@ def build_custom_checkers(by_lang):
|
||||
'strip': '\n'},
|
||||
{'pattern': '{\w',
|
||||
'description': "Missing whitespace after '{' in CSS (should be newline)."},
|
||||
]) + whitespace_rules # type: RuleList
|
||||
]) + whitespace_rules # type: RuleList
|
||||
prose_style_rules = [
|
||||
{'pattern': '[^\/\#\-\"]([jJ]avascript)', # exclude usage in hrefs/divs
|
||||
'description': "javascript should be spelled JavaScript"},
|
||||
@@ -446,7 +446,7 @@ def build_custom_checkers(by_lang):
|
||||
'<td><img alt=":heart:" class="emoji" src="/static/generated/emoji/images/emoji/heart.png" title=":heart:" /></td>')
|
||||
]),
|
||||
'description': "`title` value should be translatable."},
|
||||
] # type: RuleList
|
||||
] # type: RuleList
|
||||
handlebars_rules = html_rules + [
|
||||
{'pattern': "[<]script",
|
||||
'description': "Do not use inline <script> tags here; put JavaScript in static/js instead."},
|
||||
|
||||
@@ -578,7 +578,7 @@ def do_set_realm_default_language(realm, default_language):
|
||||
op="update",
|
||||
property="default_language",
|
||||
value=default_language
|
||||
)
|
||||
)
|
||||
send_event(event, active_user_ids(realm))
|
||||
|
||||
def do_set_realm_waiting_period_threshold(realm, threshold):
|
||||
|
||||
@@ -78,7 +78,7 @@ cache_fillers = {
|
||||
# 'message': (message_fetch_objects, message_cache_items, 3600 * 24, 1000),
|
||||
'huddle': (lambda: Huddle.objects.select_related().all(), huddle_cache_items, 3600*24*7, 10000),
|
||||
'session': (lambda: Session.objects.all(), session_cache_items, 3600*24*7, 10000),
|
||||
} # type: Dict[str, Tuple[Callable[[], List[Any]], Callable[[Dict[Text, Any], Any], None], int, int]]
|
||||
} # type: Dict[str, Tuple[Callable[[], List[Any]], Callable[[Dict[Text, Any], Any], None], int, int]]
|
||||
|
||||
def fill_remote_cache(cache):
|
||||
# type: (str) -> None
|
||||
|
||||
@@ -21,8 +21,8 @@ def wrapper_execute(self, action, sql, params=()):
|
||||
stop = time.time()
|
||||
duration = stop - start
|
||||
self.connection.queries.append({
|
||||
'time': "%.3f" % duration,
|
||||
})
|
||||
'time': "%.3f" % duration,
|
||||
})
|
||||
|
||||
class TimeTrackingCursor(cursor):
|
||||
"""A psycopg2 cursor class that tracks the time spent executing queries."""
|
||||
|
||||
@@ -171,7 +171,7 @@ def handle_digest_email(user_profile_id, cutoff):
|
||||
template_payload.update({
|
||||
'name': user_profile.full_name,
|
||||
'unsubscribe_link': one_click_unsubscribe_link(user_profile, "digest")
|
||||
})
|
||||
})
|
||||
|
||||
# Gather recent missed PMs, re-using the missed PM email logic.
|
||||
# You can't have an unread message that you sent, but when testing
|
||||
|
||||
@@ -259,8 +259,7 @@ class Config(object):
|
||||
may be deeper issues going on.''' % (
|
||||
self.table,
|
||||
self.id_source[0],
|
||||
self.virtual_parent.table,
|
||||
))
|
||||
self.virtual_parent.table))
|
||||
|
||||
|
||||
def export_from_config(response, config, seed_object=None, context=None):
|
||||
@@ -589,7 +588,7 @@ def fetch_user_profile_cross_realm(response, config, context):
|
||||
get_user_profile_by_email(settings.NOTIFICATION_BOT),
|
||||
get_user_profile_by_email(settings.EMAIL_GATEWAY_BOT),
|
||||
get_user_profile_by_email(settings.WELCOME_BOT),
|
||||
]]
|
||||
]]
|
||||
|
||||
def fetch_attachment_data(response, realm_id, message_ids):
|
||||
# type: (TableData, int, Set[int]) -> None
|
||||
|
||||
@@ -10,7 +10,7 @@ from zerver.lib.cache import bounce_key_prefix_for_testing
|
||||
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
|
||||
from zerver.lib.test_helpers import (
|
||||
get_all_templates, write_instrumentation_reports,
|
||||
)
|
||||
)
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -48,7 +48,7 @@ CREATE TRIGGER zerver_message_update_search_tsvector_async
|
||||
BEFORE INSERT OR UPDATE OF subject, rendered_content ON zerver_message
|
||||
FOR EACH ROW EXECUTE PROCEDURE append_to_fts_update_log();
|
||||
"""),
|
||||
]
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
|
||||
@@ -1322,7 +1322,7 @@ class UserPresence(models.Model):
|
||||
push_enabled=row['user_profile__enable_offline_push_notifications'],
|
||||
has_push_devices=row['user_profile__id'] in mobile_user_ids,
|
||||
is_mirror_dummy=row['user_profile__is_mirror_dummy'],
|
||||
)
|
||||
)
|
||||
user_statuses[row['user_profile__email']][row['client__name']] = info
|
||||
|
||||
return user_statuses
|
||||
|
||||
@@ -827,19 +827,19 @@ class BugdownTest(TestCase):
|
||||
self.assertEqual(
|
||||
converted,
|
||||
"<p>**test**</p>",
|
||||
)
|
||||
)
|
||||
msg = "* test"
|
||||
converted = bugdown.convert(msg, message_realm=realm, message=message)
|
||||
self.assertEqual(
|
||||
converted,
|
||||
"<p>* test</p>",
|
||||
)
|
||||
)
|
||||
msg = "https://lists.debian.org/debian-ctte/2014/02/msg00173.html"
|
||||
converted = bugdown.convert(msg, message_realm=realm, message=message)
|
||||
self.assertEqual(
|
||||
converted,
|
||||
'<p><a href="https://lists.debian.org/debian-ctte/2014/02/msg00173.html" target="_blank" title="https://lists.debian.org/debian-ctte/2014/02/msg00173.html">https://lists.debian.org/debian-ctte/2014/02/msg00173.html</a></p>',
|
||||
)
|
||||
)
|
||||
|
||||
class BugdownApiTests(ZulipTestCase):
|
||||
def test_render_message_api(self):
|
||||
|
||||
@@ -29,7 +29,7 @@ from zerver.decorator import (
|
||||
get_client_name, internal_notify_view, is_local_addr,
|
||||
rate_limit, validate_api_key, logged_in_and_active,
|
||||
return_success_on_head_request
|
||||
)
|
||||
)
|
||||
from zerver.lib.validator import (
|
||||
check_string, check_dict, check_bool, check_int, check_list
|
||||
)
|
||||
@@ -60,7 +60,7 @@ class DecoratorTestCase(TestCase):
|
||||
GET=dict(),
|
||||
POST=dict(),
|
||||
META=dict(),
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(get_client_name(req, is_json_view=True), 'website')
|
||||
self.assertEqual(get_client_name(req, is_json_view=False), 'Unspecified')
|
||||
@@ -69,7 +69,7 @@ class DecoratorTestCase(TestCase):
|
||||
GET=dict(),
|
||||
POST=dict(),
|
||||
META=dict(HTTP_USER_AGENT='Mozilla/bla bla bla'),
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(get_client_name(req, is_json_view=True), 'website')
|
||||
self.assertEqual(get_client_name(req, is_json_view=False), 'Mozilla')
|
||||
@@ -78,7 +78,7 @@ class DecoratorTestCase(TestCase):
|
||||
GET=dict(),
|
||||
POST=dict(),
|
||||
META=dict(HTTP_USER_AGENT='ZulipDesktop/bla bla bla'),
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(get_client_name(req, is_json_view=True), 'ZulipDesktop')
|
||||
self.assertEqual(get_client_name(req, is_json_view=False), 'ZulipDesktop')
|
||||
@@ -87,7 +87,7 @@ class DecoratorTestCase(TestCase):
|
||||
GET=dict(client='fancy phone'),
|
||||
POST=dict(),
|
||||
META=dict(),
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(get_client_name(req, is_json_view=True), 'fancy phone')
|
||||
self.assertEqual(get_client_name(req, is_json_view=False), 'fancy phone')
|
||||
@@ -782,7 +782,7 @@ class TestInternalNotifyView(TestCase):
|
||||
req = self.Request(
|
||||
POST=dict(secret=secret),
|
||||
META=dict(REMOTE_ADDR='127.0.0.1'),
|
||||
)
|
||||
)
|
||||
|
||||
req._tornado_handler = 'set'
|
||||
with self.settings(SHARED_SECRET=secret):
|
||||
@@ -796,7 +796,7 @@ class TestInternalNotifyView(TestCase):
|
||||
req = self.Request(
|
||||
POST=dict(secret=secret),
|
||||
META=dict(REMOTE_ADDR='127.0.0.1'),
|
||||
)
|
||||
)
|
||||
|
||||
with self.settings(SHARED_SECRET='broken'):
|
||||
self.assertFalse(authenticate_notify(req))
|
||||
@@ -808,7 +808,7 @@ class TestInternalNotifyView(TestCase):
|
||||
req = self.Request(
|
||||
POST=dict(secret=secret),
|
||||
META=dict(REMOTE_ADDR='3.3.3.3'),
|
||||
)
|
||||
)
|
||||
|
||||
with self.settings(SHARED_SECRET=secret):
|
||||
self.assertFalse(authenticate_notify(req))
|
||||
|
||||
@@ -284,7 +284,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
queue_timeout = 600,
|
||||
last_connection_time = time.time(),
|
||||
narrow = [])
|
||||
)
|
||||
)
|
||||
# hybrid_state = initial fetch state + re-applying events triggered by our action
|
||||
# normal_state = do action then fetch at the end (the "normal" code path)
|
||||
hybrid_state = fetch_initial_state_data(self.user_profile, event_types, "")
|
||||
@@ -553,7 +553,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('op', equals('update')),
|
||||
('property', equals('default_language')),
|
||||
('value', check_string),
|
||||
])
|
||||
])
|
||||
events = self.do_test(lambda: do_set_realm_default_language(self.user_profile.realm, 'de'))
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
@@ -631,7 +631,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('setting_name', equals('twenty_four_hour_time')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_twenty_four_hour_time(self.user_profile, setting_value))
|
||||
@@ -645,7 +645,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('setting_name', equals('left_side_userlist')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_left_side_userlist(self.user_profile, setting_value))
|
||||
@@ -659,7 +659,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_stream_desktop_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_stream_desktop_notifications(self.user_profile, setting_value))
|
||||
@@ -673,7 +673,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_stream_sounds')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_stream_sounds(self.user_profile, setting_value))
|
||||
@@ -687,7 +687,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_desktop_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_desktop_notifications(self.user_profile, setting_value))
|
||||
@@ -701,7 +701,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_sounds')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_sounds(self.user_profile, setting_value))
|
||||
@@ -715,7 +715,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_offline_email_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_offline_email_notifications(self.user_profile, setting_value))
|
||||
@@ -729,7 +729,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_offline_push_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_offline_push_notifications(self.user_profile, setting_value))
|
||||
@@ -743,7 +743,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_online_push_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_online_push_notifications(self.user_profile, setting_value))
|
||||
@@ -757,7 +757,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('pm_content_in_desktop_notifications')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_pm_content_in_desktop_notifications(self.user_profile, setting_value))
|
||||
@@ -771,7 +771,7 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
('notification_name', equals('enable_digest_emails')),
|
||||
('user', check_string),
|
||||
('setting', check_bool),
|
||||
])
|
||||
])
|
||||
# The first False is probably a noop, then we get transitions in both directions.
|
||||
for setting_value in [False, True, False]:
|
||||
events = self.do_test(lambda: do_change_enable_digest_emails(self.user_profile, setting_value))
|
||||
|
||||
@@ -1527,7 +1527,7 @@ class StarTests(ZulipTestCase):
|
||||
|
||||
sent_message = UserMessage.objects.filter(
|
||||
user_profile=get_user_profile_by_email(test_email)
|
||||
).order_by("id").reverse()[0]
|
||||
).order_by("id").reverse()[0]
|
||||
self.assertEqual(sent_message.message.content, content)
|
||||
self.assertFalse(sent_message.flags.starred)
|
||||
|
||||
|
||||
@@ -418,7 +418,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||
op='remove',
|
||||
type='subscription',
|
||||
subscriptions=[{'name': active_name, 'stream_id': stream.id}]
|
||||
))
|
||||
))
|
||||
else:
|
||||
# You could delete the stream, but you weren't on it so you don't
|
||||
# receive an unsubscription event.
|
||||
@@ -1470,7 +1470,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
self.test_email,
|
||||
streams_to_sub,
|
||||
dict(principals=ujson.dumps([email1, email2])),
|
||||
)
|
||||
)
|
||||
self.assert_max_length(queries, 43)
|
||||
|
||||
self.assert_length(events, 8)
|
||||
|
||||
@@ -464,23 +464,20 @@ class AdminCreateUserTest(ZulipTestCase):
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
email='romeo@not-zulip.com',
|
||||
)
|
||||
)
|
||||
))
|
||||
self.assert_json_error(result, "Missing 'password' argument")
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
email='romeo@not-zulip.com',
|
||||
password='xxxx',
|
||||
)
|
||||
)
|
||||
))
|
||||
self.assert_json_error(result, "Missing 'full_name' argument")
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
email='romeo@not-zulip.com',
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
)
|
||||
)
|
||||
))
|
||||
self.assert_json_error(result, "Missing 'short_name' argument")
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
@@ -488,8 +485,7 @@ class AdminCreateUserTest(ZulipTestCase):
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='Romeo',
|
||||
)
|
||||
)
|
||||
))
|
||||
self.assert_json_error(result, "Bad name or username")
|
||||
|
||||
result = self.client_post("/json/users", dict(
|
||||
@@ -497,8 +493,7 @@ class AdminCreateUserTest(ZulipTestCase):
|
||||
password='xxxx',
|
||||
full_name='Romeo Montague',
|
||||
short_name='Romeo',
|
||||
)
|
||||
)
|
||||
))
|
||||
self.assert_json_error(result,
|
||||
"Email 'romeo@not-zulip.com' does not belong to domain 'zulip.com'")
|
||||
|
||||
@@ -789,7 +784,7 @@ class BotTest(ZulipTestCase):
|
||||
bot_info = dict(
|
||||
full_name='',
|
||||
short_name='',
|
||||
)
|
||||
)
|
||||
result = self.client_post("/json/bots", bot_info)
|
||||
self.assert_json_error(result, 'Bad name or username')
|
||||
self.assert_num_bots_equal(0)
|
||||
@@ -840,7 +835,7 @@ class BotTest(ZulipTestCase):
|
||||
bot_info = dict(
|
||||
full_name='Duplicate',
|
||||
short_name='hambot',
|
||||
)
|
||||
)
|
||||
result = self.client_post("/json/bots", bot_info)
|
||||
self.assert_json_error(result, 'Username already in use')
|
||||
|
||||
@@ -871,7 +866,7 @@ class BotTest(ZulipTestCase):
|
||||
short_name='whatever',
|
||||
file1=fp1,
|
||||
file2=fp2,
|
||||
)
|
||||
)
|
||||
result = self.client_post("/json/bots", bot_info)
|
||||
self.assert_json_error(result, 'You may only upload one file at a time')
|
||||
self.assert_num_bots_equal(0)
|
||||
|
||||
@@ -129,5 +129,5 @@ def api_endpoint_docs(request):
|
||||
'zerver/api_endpoints.html', {
|
||||
'content': calls,
|
||||
'langs': langs,
|
||||
},
|
||||
},
|
||||
request=request)
|
||||
|
||||
@@ -47,7 +47,7 @@ email_unsubscribers = {
|
||||
"missed_messages": ("missed messages", do_missedmessage_unsubscribe),
|
||||
"welcome": ("welcome", do_welcome_unsubscribe),
|
||||
"digest": ("digest", do_digest_unsubscribe)
|
||||
}
|
||||
}
|
||||
|
||||
# Login NOT required. These are for one-click unsubscribes.
|
||||
def email_unsubscribe(request, type, token):
|
||||
|
||||
@@ -122,7 +122,7 @@ def api_freshdesk_webhook(request, user_profile, payload=REQ(argument_type='body
|
||||
"triggered_event", "ticket_id", "ticket_url", "ticket_type",
|
||||
"ticket_subject", "ticket_description", "ticket_status",
|
||||
"ticket_priority", "requester_name", "requester_email",
|
||||
]
|
||||
]
|
||||
|
||||
for key in required_keys:
|
||||
if ticket_data.get(key) is None:
|
||||
|
||||
@@ -136,7 +136,7 @@ def get_create_or_delete_body(payload, action):
|
||||
action,
|
||||
ref_type,
|
||||
payload['ref']
|
||||
).rstrip()
|
||||
).rstrip()
|
||||
|
||||
def get_commit_comment_body(payload):
|
||||
# type: (Dict[str, Any]) -> Text
|
||||
|
||||
@@ -157,11 +157,10 @@ def parse_create_or_delete(message):
|
||||
return {
|
||||
'type': message["type"],
|
||||
'event': message["action"],
|
||||
'values':
|
||||
{
|
||||
'user': get_owner_name(message),
|
||||
'subject': get_subject(message)
|
||||
}
|
||||
'values': {
|
||||
'user': get_owner_name(message),
|
||||
'subject': get_subject(message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ class ErrorReporter(QueueProcessingWorker):
|
||||
method='POST',
|
||||
url='deployments/report_error',
|
||||
make_request=(lambda type, report: {'type': type, 'report': simplejson.dumps(report)}),
|
||||
)
|
||||
)
|
||||
QueueProcessingWorker.start(self)
|
||||
|
||||
def consume(self, event):
|
||||
|
||||
@@ -223,7 +223,7 @@ class Command(BaseCommand):
|
||||
("Fred Sipb (MIT)", "sipbtest@mit.edu"),
|
||||
("Athena Consulting Exchange User (MIT)", "starnine@mit.edu"),
|
||||
("Esp Classroom (MIT)", "espuser@mit.edu"),
|
||||
]
|
||||
]
|
||||
create_users(mit_realm, testsuite_mit_users)
|
||||
|
||||
# These bots are directly referenced from code and thus
|
||||
@@ -234,7 +234,7 @@ class Command(BaseCommand):
|
||||
("Zulip New User Bot", "new-user-bot@zulip.com"),
|
||||
("Zulip Error Bot", "error-bot@zulip.com"),
|
||||
("Zulip Default Bot", "default-bot@zulip.com"),
|
||||
]
|
||||
]
|
||||
zulip_realm_bots.extend(all_realm_bots)
|
||||
create_users(zulip_realm, zulip_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
|
||||
|
||||
@@ -294,12 +294,12 @@ class Command(BaseCommand):
|
||||
("Zulip Commit Bot", "commit-bot@zulip.com"),
|
||||
("Zulip Trac Bot", "trac-bot@zulip.com"),
|
||||
("Zulip Nagios Bot", "nagios-bot@zulip.com"),
|
||||
]
|
||||
]
|
||||
create_users(zulip_realm, internal_zulip_users_nosubs, bot_type=UserProfile.DEFAULT_BOT)
|
||||
|
||||
zulip_cross_realm_bots = [
|
||||
("Zulip Feedback Bot", "feedback@zulip.com"),
|
||||
]
|
||||
]
|
||||
create_users(zulip_realm, zulip_cross_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
|
||||
|
||||
# Mark all messages as read
|
||||
|
||||
@@ -443,4 +443,4 @@ AUTH_BACKEND_NAME_MAP = {
|
||||
u'Google': GoogleMobileOauth2Backend,
|
||||
u'LDAP': ZulipLDAPAuthBackend,
|
||||
u'RemoteUser': ZulipRemoteUserBackend,
|
||||
} # type: Dict[Text, Any]
|
||||
} # type: Dict[Text, Any]
|
||||
|
||||
@@ -37,4 +37,4 @@ legacy_urls = [
|
||||
url(r'^json/upload_file$', zerver.views.upload.json_upload_file),
|
||||
url(r'^json/messages_in_narrow$', zerver.views.messages.json_messages_in_narrow),
|
||||
url(r'^json/set_muted_topics$', zerver.views.muting.json_set_muted_topics),
|
||||
]
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ AUTHENTICATION_BACKENDS = (
|
||||
# 'zproject.backends.GitHubAuthBackend', # GitHub auth, setup below
|
||||
# 'zproject.backends.ZulipLDAPAuthBackend', # LDAP, setup below
|
||||
# 'zproject.backends.ZulipRemoteUserBackend', # Local SSO, setup docs on readthedocs
|
||||
)
|
||||
)
|
||||
|
||||
# To enable Google authentication, you need to do the following:
|
||||
#
|
||||
|
||||
@@ -378,24 +378,23 @@ DATABASES = {"default": {
|
||||
'CONN_MAX_AGE': 600,
|
||||
'OPTIONS': {
|
||||
'connection_factory': TimeTrackingConnection
|
||||
},
|
||||
},
|
||||
}
|
||||
}}
|
||||
|
||||
if DEVELOPMENT:
|
||||
LOCAL_DATABASE_PASSWORD = get_secret("local_database_password")
|
||||
DATABASES["default"].update({
|
||||
'PASSWORD': LOCAL_DATABASE_PASSWORD,
|
||||
'HOST': 'localhost'
|
||||
})
|
||||
})
|
||||
elif REMOTE_POSTGRES_HOST != '':
|
||||
DATABASES['default'].update({
|
||||
'HOST': REMOTE_POSTGRES_HOST,
|
||||
})
|
||||
})
|
||||
if get_secret("postgres_password") is not None:
|
||||
DATABASES['default'].update({
|
||||
'PASSWORD': get_secret("postgres_password"),
|
||||
})
|
||||
})
|
||||
if REMOTE_POSTGRES_SSLMODE != '':
|
||||
DATABASES['default']['OPTIONS']['sslmode'] = REMOTE_POSTGRES_SSLMODE
|
||||
else:
|
||||
@@ -454,7 +453,7 @@ CACHES = {
|
||||
|
||||
RATE_LIMITING_RULES = [
|
||||
(60, 100), # 100 requests max every minute
|
||||
]
|
||||
]
|
||||
DEBUG_RATE_LIMITING = DEBUG
|
||||
REDIS_PASSWORD = get_secret('redis_password')
|
||||
|
||||
@@ -733,14 +732,14 @@ JS_SPECS = {
|
||||
'js/blueslip.js',
|
||||
'third/bootstrap/js/bootstrap.js',
|
||||
'js/common.js',
|
||||
],
|
||||
],
|
||||
'output_filename': 'min/common.js'
|
||||
},
|
||||
'signup': {
|
||||
'source_filenames': [
|
||||
'js/portico/signup.js',
|
||||
'node_modules/jquery-validation/dist/jquery.validate.js',
|
||||
],
|
||||
],
|
||||
'output_filename': 'min/signup.js'
|
||||
},
|
||||
'api': {
|
||||
@@ -898,7 +897,7 @@ ZULIP_PATHS = [
|
||||
("STATS_DIR", "/home/zulip/stats"),
|
||||
("DIGEST_LOG_PATH", "/var/log/zulip/digest.log"),
|
||||
("ANALYTICS_LOG_PATH", "/var/log/zulip/analytics.log"),
|
||||
]
|
||||
]
|
||||
|
||||
# The Event log basically logs most significant database changes,
|
||||
# which can be useful for debugging.
|
||||
|
||||
Reference in New Issue
Block a user