diff --git a/zerver/lib/hotspots.py b/zerver/lib/hotspots.py index 98fed491b5..e8c3a92b1e 100644 --- a/zerver/lib/hotspots.py +++ b/zerver/lib/hotspots.py @@ -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'], diff --git a/zerver/tests/test_hotspots.py b/zerver/tests/test_hotspots.py index 8126263ba4..600d15da45 100644 --- a/zerver/tests/test_hotspots.py +++ b/zerver/tests/test_hotspots.py @@ -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') diff --git a/zproject/dev_settings.py b/zproject/dev_settings.py index 3bbbcc4663..1753cc82b0 100644 --- a/zproject/dev_settings.py +++ b/zproject/dev_settings.py @@ -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 diff --git a/zproject/settings.py b/zproject/settings.py index 865e738e59..870c096230 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -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.