def test_home(self) -> None:
    html_bits = ['Compose your message here...', 'Exclude messages with topic', 'Keyboard shortcuts', 'Loading...', 'Manage streams', 'Narrow by topic', 'Next message', 'Search streams', 'Welcome to Zulip', 'app-stubentry.js', 'var page_params']
    expected_keys = ['alert_words', 'avatar_source', 'avatar_url', 'avatar_url_medium', 'bot_types', 'can_create_streams', 'cross_realm_bots', 'custom_profile_field_types', 'custom_profile_fields', 'debug_mode', 'default_language', 'default_language_name', 'delivery_email', 'dense_mode', 'development_environment', 'email', 'emojiset', 'emojiset_choices', 'enable_desktop_notifications', 'enable_digest_emails', 'enable_offline_email_notifications', 'enable_offline_push_notifications', 'enable_online_push_notifications', 'enable_sounds', 'enable_stream_desktop_notifications', 'enable_stream_email_notifications', 'enable_stream_push_notifications', 'enable_stream_sounds', 'enter_sends', 'first_in_realm', 'full_name', 'furthest_read_time', 'has_mobile_devices', 'have_initial_messages', 'high_contrast_mode', 'hotspots', 'initial_servertime', 'is_admin', 'is_guest', 'jitsi_server_url', 'language_list', 'language_list_dbl_col', 'last_event_id', 'left_side_userlist', 'login_page', 'max_avatar_file_size', 'max_icon_file_size', 'max_message_id', 'maxfilesize', 'message_content_in_email_notifications', 'muted_topics', 'narrow', 'narrow_stream', 'needs_tutorial', 'never_subscribed', 'night_mode', 'password_min_guesses', 'password_min_length', 'pm_content_in_desktop_notifications', 'pointer', 'poll_timeout', 'presences', 'prompt_for_invites', 'queue_id', 'realm_add_emoji_by_admins_only', 'realm_allow_community_topic_editing', 'realm_allow_edit_history', 'realm_allow_message_deleting', 'realm_allow_message_editing', 'realm_authentication_methods', 'realm_available_video_chat_providers', 'realm_bot_creation_policy', 'realm_bot_domain', 'realm_bots', 'realm_create_stream_by_admins_only', 'realm_default_language', 'realm_default_stream_groups', 'realm_default_streams', 'realm_default_twenty_four_hour_time', 'realm_description', 'realm_disallow_disposable_email_addresses', 'realm_domains', 'realm_email_auth_enabled', 'realm_email_changes_disabled', 'realm_embedded_bots', 'realm_emoji', 'realm_filters', 'realm_google_hangouts_domain', 'realm_icon_source', 'realm_icon_url', 'realm_inline_image_preview', 'realm_inline_url_embed_preview', 'realm_invite_by_admins_only', 'realm_invite_required', 'realm_is_zephyr_mirror_realm', 'realm_mandatory_topics', 'realm_message_content_delete_limit_seconds', 'realm_message_content_edit_limit_seconds', 'realm_message_retention_days', 'realm_name', 'realm_name_changes_disabled', 'realm_name_in_notifications', 'realm_non_active_users', 'realm_notifications_stream_id', 'realm_password_auth_enabled', 'realm_presence_disabled', 'realm_push_notifications_enabled', 'realm_restricted_to_domain', 'realm_send_welcome_emails', 'realm_show_digest_email', 'realm_signup_notifications_stream_id', 'realm_uri', 'realm_user_groups', 'realm_users', 'realm_video_chat_provider', 'realm_waiting_period_threshold', 'root_domain_uri', 'save_stacktraces', 'search_pills_enabled', 'server_generation', 'server_inline_image_preview', 'server_inline_url_embed_preview', 'stream_description_max_length', 'stream_name_max_length', 'subscriptions', 'test_suite', 'timezone', 'translate_emoticons', 'translation_data', 'twenty_four_hour_time', 'two_fa_enabled', 'two_fa_enabled_user', 'unread_msgs', 'unsubscribed', 'use_websockets', 'user_id', 'warn_no_email', 'zulip_version']
    email = self.example_email('hamlet')
    result = self.client_get('/')
    self.assertEqual(result.status_code, 302)
    self.login(email)
    bot_info = {'full_name': 'The Bot of Hamlet', 'short_name': 'hambot'}
    self.client_post('/json/bots', bot_info)
    flush_per_request_caches()
    with queries_captured() as queries:
        with patch('zerver.lib.cache.cache_set') as cache_mock:
            result = self._get_home_page(stream='Denmark')
    self.assert_length(queries, 41)
    self.assert_length(cache_mock.call_args_list, 7)
    html = result.content.decode('utf-8')
    for html_bit in html_bits:
        if (html_bit not in html):
            raise AssertionError(('%s not in result' % (html_bit,)))
    page_params = self._get_page_params(result)
    actual_keys = sorted([str(k) for k in page_params.keys()])
    self.assertEqual(actual_keys, expected_keys)
    realm_bots_expected_keys = ['api_key', 'avatar_url', 'bot_type', 'default_all_public_streams', 'default_events_register_stream', 'default_sending_stream', 'email', 'full_name', 'is_active', 'owner', 'services', 'user_id']
    realm_bots_actual_keys = sorted([str(key) for key in page_params['realm_bots'][0].keys()])
    self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys)
def test_home(self) -> None:
    html_bits = ['Compose your message here...', 'Exclude messages with topic', 'Keyboard shortcuts', 'Loading...', 'Manage streams', 'Narrow by topic', 'Next message', 'Search streams', 'Welcome to Zulip', 'app-stubentry.js', 'var page_params']
    expected_keys = ['alert_words', 'avatar_source', 'avatar_url', 'avatar_url_medium', 'bot_types', 'can_create_streams', 'cross_realm_bots', 'custom_profile_field_types', 'custom_profile_fields', 'debug_mode', 'default_language', 'default_language_name', 'delivery_email', 'dense_mode', 'development_environment', 'email', 'emojiset', 'emojiset_choices', 'enable_desktop_notifications', 'enable_digest_emails', 'enable_offline_email_notifications', 'enable_offline_push_notifications', 'enable_online_push_notifications', 'enable_sounds', 'enable_stream_desktop_notifications', 'enable_stream_email_notifications', 'enable_stream_push_notifications', 'enable_stream_sounds', 'enter_sends', 'first_in_realm', 'full_name', 'furthest_read_time', 'has_mobile_devices', 'have_initial_messages', 'high_contrast_mode', 'hotspots', 'initial_servertime', 'is_admin', 'is_guest', 'jitsi_server_url', 'language_list', 'language_list_dbl_col', 'last_event_id', 'left_side_userlist', 'login_page', 'max_avatar_file_size', 'max_icon_file_size', 'max_message_id', 'maxfilesize', 'message_content_in_email_notifications', 'muted_topics', 'narrow', 'narrow_stream', 'needs_tutorial', 'never_subscribed', 'night_mode', 'password_min_guesses', 'password_min_length', 'pm_content_in_desktop_notifications', 'pointer', 'poll_timeout', 'presences', 'prompt_for_invites', 'queue_id', 'realm_add_emoji_by_admins_only', 'realm_allow_community_topic_editing', 'realm_allow_edit_history', 'realm_allow_message_deleting', 'realm_allow_message_editing', 'realm_authentication_methods', 'realm_available_video_chat_providers', 'realm_bot_creation_policy', 'realm_bot_domain', 'realm_bots', 'realm_create_stream_by_admins_only', 'realm_default_language', 'realm_default_stream_groups', 'realm_default_streams', 'realm_default_twenty_four_hour_time', 'realm_description', 'realm_disallow_disposable_email_addresses', 'realm_domains', 'realm_email_auth_enabled', 'realm_email_changes_disabled', 'realm_embedded_bots', 'realm_emoji', 'realm_filters', 'realm_google_hangouts_domain', 'realm_icon_source', 'realm_icon_url', 'realm_inline_image_preview', 'realm_inline_url_embed_preview', 'realm_invite_by_admins_only', 'realm_invite_required', 'realm_is_zephyr_mirror_realm', 'realm_mandatory_topics', 'realm_message_content_delete_limit_seconds', 'realm_message_content_edit_limit_seconds', 'realm_message_retention_days', 'realm_name', 'realm_name_changes_disabled', 'realm_name_in_notifications', 'realm_non_active_users', 'realm_notifications_stream_id', 'realm_password_auth_enabled', 'realm_presence_disabled', 'realm_push_notifications_enabled', 'realm_restricted_to_domain', 'realm_send_welcome_emails', 'realm_show_digest_email', 'realm_signup_notifications_stream_id', 'realm_uri', 'realm_user_groups', 'realm_users', 'realm_video_chat_provider', 'realm_waiting_period_threshold', 'root_domain_uri', 'save_stacktraces', 'search_pills_enabled', 'server_generation', 'server_inline_image_preview', 'server_inline_url_embed_preview', 'stream_description_max_length', 'stream_name_max_length', 'subscriptions', 'test_suite', 'timezone', 'translate_emoticons', 'translation_data', 'twenty_four_hour_time', 'two_fa_enabled', 'two_fa_enabled_user', 'unread_msgs', 'unsubscribed', 'use_websockets', 'user_id', 'warn_no_email', 'zulip_version']
    email = self.example_email('hamlet')
    result = self.client_get('/')
    self.assertEqual(result.status_code, 302)
    self.login(email)
    bot_info = {'full_name': 'The Bot of Hamlet', 'short_name': 'hambot'}
    self.client_post('/json/bots', bot_info)
    flush_per_request_caches()
    with queries_captured() as queries:
        with patch('zerver.lib.cache.cache_set') as cache_mock:
            result = self._get_home_page(stream='Denmark')
    self.assert_length(queries, 41)
    self.assert_length(cache_mock.call_args_list, 7)
    html = result.content.decode('utf-8')
    for html_bit in html_bits:
        if (html_bit not in html):
            raise AssertionError(('%s not in result' % (html_bit,)))
    page_params = self._get_page_params(result)
    actual_keys = sorted([str(k) for k in page_params.keys()])
    self.assertEqual(actual_keys, expected_keys)
    realm_bots_expected_keys = ['api_key', 'avatar_url', 'bot_type', 'default_all_public_streams', 'default_events_register_stream', 'default_sending_stream', 'email', 'full_name', 'is_active', 'owner', 'services', 'user_id']
    realm_bots_actual_keys = sorted([str(key) for key in page_params['realm_bots'][0].keys()])
    self.assertEqual(realm_bots_actual_keys, realm_bots_expected_keys)