@slow('creating users and loading home page')
def test_people(self) -> None:
    hamlet = self.example_user('hamlet')
    realm = get_realm('zulip')
    self.login(hamlet.email)
    for i in range(3):
        self.create_bot(owner=hamlet, bot_email=('example@example.com' % (i,)), bot_name=('Bot %d' % (i,)))
    for i in range(3):
        self.create_non_active_user(realm=realm, email=('example@example.com' % (i,)), name=('Defunct User %d' % (i,)))
    result = self._get_home_page()
    page_params = self._get_page_params(result)
    "\n        We send three lists of users.  The first two below are disjoint\n        lists of users, and the records we send for them have identical\n        structure.\n\n        The realm_bots bucket is somewhat redundant, since all bots will\n        be in one of the first two buckets.  They do include fields, however,\n        that normal users don't care about, such as default_sending_stream.\n        "
    buckets = ['realm_users', 'realm_non_active_users', 'realm_bots']
    for field in buckets:
        users = page_params[field]
        self.assertTrue((len(users) >= 3), field)
        for rec in users:
            self.assertEqual(rec['user_id'], get_user(rec['email'], realm).id)
            if (field == 'realm_bots'):
                self.assertNotIn('is_bot', rec)
                self.assertIn('is_active', rec)
                self.assertIn('owner', rec)
            else:
                self.assertIn('is_bot', rec)
                self.assertNotIn('is_active', rec)
    active_emails = {p['email'] for p in page_params['realm_users']}
    non_active_emails = {p['email'] for p in page_params['realm_non_active_users']}
    bot_emails = {p['email'] for p in page_params['realm_bots']}
    self.assertIn(hamlet.email, active_emails)
    self.assertIn('example@example.com', non_active_emails)
    self.assertIn('example@example.com', bot_emails)
    self.assertIn('example@example.com', active_emails)
    self.assertNotIn(hamlet.email, non_active_emails)
    self.assertNotIn('example@example.com', active_emails)
    cross_bots = page_params['cross_realm_bots']
    self.assertEqual(len(cross_bots), 5)
    cross_bots.sort(key=(lambda d: d['email']))
    notification_bot = self.notification_bot()
    by_email = (lambda d: d['email'])
    self.assertEqual(sorted(cross_bots, key=by_email), sorted([dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Zulip New User Bot', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Email Gateway', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Zulip Feedback Bot', is_bot=True), dict(user_id=notification_bot.id, is_admin=False, email=notification_bot.email, full_name='Notification Bot', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Welcome Bot', is_bot=True)], key=by_email))
@slow('creating users and loading home page')
def test_people(self) -> None:
    hamlet = self.example_user('hamlet')
    realm = get_realm('zulip')
    self.login(hamlet.email)
    for i in range(3):
        self.create_bot(owner=hamlet, bot_email=('example@example.com' % (i,)), bot_name=('Bot %d' % (i,)))
    for i in range(3):
        self.create_non_active_user(realm=realm, email=('example@example.com' % (i,)), name=('Defunct User %d' % (i,)))
    result = self._get_home_page()
    page_params = self._get_page_params(result)
    "\n        We send three lists of users.  The first two below are disjoint\n        lists of users, and the records we send for them have identical\n        structure.\n\n        The realm_bots bucket is somewhat redundant, since all bots will\n        be in one of the first two buckets.  They do include fields, however,\n        that normal users don't care about, such as default_sending_stream.\n        "
    buckets = ['realm_users', 'realm_non_active_users', 'realm_bots']
    for field in buckets:
        users = page_params[field]
        self.assertTrue((len(users) >= 3), field)
        for rec in users:
            self.assertEqual(rec['user_id'], get_user(rec['email'], realm).id)
            if (field == 'realm_bots'):
                self.assertNotIn('is_bot', rec)
                self.assertIn('is_active', rec)
                self.assertIn('owner', rec)
            else:
                self.assertIn('is_bot', rec)
                self.assertNotIn('is_active', rec)
    active_emails = {p['email'] for p in page_params['realm_users']}
    non_active_emails = {p['email'] for p in page_params['realm_non_active_users']}
    bot_emails = {p['email'] for p in page_params['realm_bots']}
    self.assertIn(hamlet.email, active_emails)
    self.assertIn('example@example.com', non_active_emails)
    self.assertIn('example@example.com', bot_emails)
    self.assertIn('example@example.com', active_emails)
    self.assertNotIn(hamlet.email, non_active_emails)
    self.assertNotIn('example@example.com', active_emails)
    cross_bots = page_params['cross_realm_bots']
    self.assertEqual(len(cross_bots), 5)
    cross_bots.sort(key=(lambda d: d['email']))
    notification_bot = self.notification_bot()
    by_email = (lambda d: d['email'])
    self.assertEqual(sorted(cross_bots, key=by_email), sorted([dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Zulip New User Bot', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Email Gateway', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Zulip Feedback Bot', is_bot=True), dict(user_id=notification_bot.id, is_admin=False, email=notification_bot.email, full_name='Notification Bot', is_bot=True), dict(user_id=get_user('example@example.com', get_realm('zulip')).id, is_admin=False, email='example@example.com', full_name='Welcome Bot', is_bot=True)], key=by_email))