mirror of https://github.com/zulip/zulip.git
Speed up message_stream in tests.py
(imported from commit 042a763cda33e38e370ed7a185e0b8cdd61a806b)
This commit is contained in:
parent
d3e3c21273
commit
3f047ec703
|
@ -57,6 +57,13 @@ def find_key_by_email(address):
|
||||||
def message_ids(result):
|
def message_ids(result):
|
||||||
return set(message['id'] for message in result['messages'])
|
return set(message['id'] for message in result['messages'])
|
||||||
|
|
||||||
|
def get_user_messages(user_profile):
|
||||||
|
query = UserMessage.objects. \
|
||||||
|
select_related("message"). \
|
||||||
|
filter(user_profile=user_profile). \
|
||||||
|
order_by('message')
|
||||||
|
return [um.message for um in query]
|
||||||
|
|
||||||
def slow(expected_run_time, slowness_reason):
|
def slow(expected_run_time, slowness_reason):
|
||||||
'''
|
'''
|
||||||
This is a decorate that annotates a test as being "known
|
This is a decorate that annotates a test as being "known
|
||||||
|
@ -156,7 +163,7 @@ class AuthedTestCase(TestCase):
|
||||||
return [subscription.user_profile for subscription in subscriptions]
|
return [subscription.user_profile for subscription in subscriptions]
|
||||||
|
|
||||||
def message_stream(self, user_profile):
|
def message_stream(self, user_profile):
|
||||||
return filter_by_subscriptions(Message.objects.all(), user_profile)
|
return get_user_messages(user_profile)
|
||||||
|
|
||||||
def assert_json_success(self, result):
|
def assert_json_success(self, result):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue