Send user_id to the client in more places.

This commit touches:

    realm_bot/add
    realm_user/add
    page_params.bot_list
    page_params.people_list
This commit is contained in:
Steve Howell 2016-10-25 18:35:32 -07:00 committed by Tim Abbott
parent 4fe5fc849e
commit 7883cecf28
4 changed files with 25 additions and 2 deletions

View File

@ -269,6 +269,7 @@ def notify_created_user(user_profile):
# type: (UserProfile) -> None
event = dict(type="realm_user", op="add",
person=dict(email=user_profile.email,
user_id=user_profile.id,
is_admin=user_profile.is_realm_admin,
full_name=user_profile.full_name,
is_bot=user_profile.is_bot))
@ -288,6 +289,7 @@ def notify_created_bot(user_profile):
event = dict(type="realm_bot", op="add",
bot=dict(email=user_profile.email,
user_id=user_profile.id,
full_name=user_profile.full_name,
api_key=user_profile.api_key,
default_sending_stream=default_sending_stream_name,
@ -2784,6 +2786,7 @@ def get_status_dict(requesting_user_profile):
def get_realm_user_dicts(user_profile):
# type: (UserProfile) -> List[Dict[str, text_type]]
return [{'email' : userdict['email'],
'user_id' : userdict['id'],
'is_admin' : userdict['is_realm_admin'],
'is_bot' : userdict['is_bot'],
'full_name' : userdict['full_name']}

View File

@ -1065,6 +1065,7 @@ def get_owned_bot_dicts(user_profile, include_all_realm_bots_if_admin=True):
from zerver.lib.avatar import get_avatar_url
return [{'email': botdict['email'],
'user_id': botdict['id'],
'full_name': botdict['full_name'],
'api_key': botdict['api_key'],
'default_sending_stream': botdict['default_sending_stream__name'],

View File

@ -624,6 +624,7 @@ class EventsRegisterTest(ZulipTestCase):
('op', equals('add')),
('bot', check_dict([
('email', check_string),
('user_id', check_int),
('full_name', check_string),
('api_key', check_string),
('default_sending_stream', check_none_or(check_string)),

View File

@ -772,12 +772,15 @@ class BotTest(ZulipTestCase):
result = self.create_bot()
self.assert_num_bots_equal(1)
bot = get_user_profile_by_email('hambot-bot@zulip.com')
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
self.assertEqual(
dict(
type='realm_bot',
op='add',
bot=dict(email='hambot-bot@zulip.com',
user_id=bot.id,
full_name='The Bot of Hamlet',
api_key=result['api_key'],
avatar_url=result['avatar_url'],
@ -931,6 +934,7 @@ class BotTest(ZulipTestCase):
type='realm_bot',
op='add',
bot=dict(email='hambot-bot@zulip.com',
user_id=profile.id,
full_name='The Bot of Hamlet',
api_key=result['api_key'],
avatar_url=result['avatar_url'],
@ -984,8 +988,8 @@ class BotTest(ZulipTestCase):
self.assert_num_bots_equal(1)
self.assertEqual(result['default_events_register_stream'], 'Denmark')
profile = get_user_profile_by_email('hambot-bot@zulip.com')
self.assertEqual(profile.default_events_register_stream.name, 'Denmark')
bot_profile = get_user_profile_by_email('hambot-bot@zulip.com')
self.assertEqual(bot_profile.default_events_register_stream.name, 'Denmark')
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
self.assertEqual(
@ -994,6 +998,7 @@ class BotTest(ZulipTestCase):
op='add',
bot=dict(email='hambot-bot@zulip.com',
full_name='The Bot of Hamlet',
user_id=bot_profile.id,
api_key=result['api_key'],
avatar_url=result['avatar_url'],
default_sending_stream=None,
@ -1962,6 +1967,19 @@ class HomeTest(ZulipTestCase):
page_params = self._get_page_params(result)
self.assertEqual(page_params['notifications_stream'], 'Denmark')
def test_people(self):
# type: () -> None
email = 'hamlet@zulip.com'
self.login(email)
result = self._get_home_page()
page_params = self._get_page_params(result)
for params in ['people_list', 'bot_list']:
users = page_params['people_list']
self.assertTrue(len(users) >= 3)
for user in users:
self.assertEqual(user['user_id'],
get_user_profile_by_email(user['email']).id)
def test_new_stream(self):
# type: () -> None
email = 'hamlet@zulip.com'