hotspots: Add ALWAYS_SEND_ALL_HOTSPOTS in dev_settings.

Replace the local variable SEND_ALL from get_next_hotspots.
Add unit test for the same.
This commit is contained in:
Nikhil Kumar Mishra 2018-03-19 01:29:10 +05:30 committed by Tim Abbott
parent a5472ddee7
commit f29a1918f3
4 changed files with 17 additions and 3 deletions

View File

@ -28,9 +28,10 @@ ALL_HOTSPOTS = {
} # type: Dict[str, Dict[str, Text]]
def get_next_hotspots(user: UserProfile) -> List[Dict[str, object]]:
# Only used for manual testing
SEND_ALL = False
if settings.DEVELOPMENT and SEND_ALL:
# For manual testing, it can be convenient to set
# ALWAYS_SEND_ALL_HOTSPOTS=True in `zproject/dev_settings.py` to
# make it easy to click on all of the hotspots.
if settings.ALWAYS_SEND_ALL_HOTSPOTS:
return [{
'name': hotspot,
'title': ALL_HOTSPOTS[hotspot]['title'],

View File

@ -6,8 +6,10 @@ from zerver.lib.test_classes import ZulipTestCase
from zerver.models import UserProfile, UserHotspot, get_realm
from zerver.views.hotspots import mark_hotspot_as_read
from django.conf import settings
from typing import Any, Dict
import ujson
import mock
# Splitting this out, since I imagine this will eventually have most of the
# complicated hotspots logic.
@ -35,6 +37,10 @@ class TestGetNextHotspots(ZulipTestCase):
self.assertEqual(self.user.tutorial_status, UserProfile.TUTORIAL_FINISHED)
self.assertEqual(get_next_hotspots(self.user), [])
def test_send_all(self) -> None:
with self.settings(DEVELOPMENT=True, ALWAYS_SEND_ALL_HOTSPOTS = True):
self.assertEqual(len(ALL_HOTSPOTS), len(get_next_hotspots(self.user)))
class TestHotspots(ZulipTestCase):
def test_do_mark_hotspot_as_read(self) -> None:
user = self.example_user('hamlet')

View File

@ -85,3 +85,6 @@ TWO_FACTOR_SMS_GATEWAY = 'two_factor.gateways.fake.Fake'
# Make sendfile use django to serve files in development
SENDFILE_BACKEND = 'sendfile.backends.development'
# Set this True to send all hotspots in development
ALWAYS_SEND_ALL_HOTSPOTS = False # type: bool

View File

@ -202,6 +202,10 @@ DEFAULT_SETTINGS = {
# Two Factor Authentication is not yet implementation-complete
'TWO_FACTOR_AUTHENTICATION_ENABLED': False,
# This is used to send all hotspots for convenient manual testing
# in development mode.
'ALWAYS_SEND_ALL_HOTSPOTS': False,
}
# These settings are not documented in prod_settings_template.py.