From 3f4551b7f3a3aa43c240bc1c2af1ba17f517cbc9 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 25 Nov 2016 17:17:38 +0100 Subject: [PATCH] New unit test. --- modoboa/core/tests/test_views.py | 9 +++++++++ modoboa/core/views/admin.py | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modoboa/core/tests/test_views.py b/modoboa/core/tests/test_views.py index de7689b04..61fa17125 100644 --- a/modoboa/core/tests/test_views.py +++ b/modoboa/core/tests/test_views.py @@ -1,5 +1,7 @@ """Core views test cases.""" +import json + from testfixtures import compare from django import forms @@ -67,6 +69,13 @@ class DashboardTestCase(ModoTestCase): self.assertEqual(response.status_code, 302) self.assertTrue(response.url.endswith(reverse("core:dashboard"))) + def test_top_notifications(self): + """Check top notifications service.""" + url = reverse("core:top_notifications_check") + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertEqual(len(json.loads(response.content)), 1) + class SettingsTestCase(ModoTestCase): """Settings tests.""" diff --git a/modoboa/core/views/admin.py b/modoboa/core/views/admin.py index e69d7e87b..9371341d2 100644 --- a/modoboa/core/views/admin.py +++ b/modoboa/core/views/admin.py @@ -114,9 +114,7 @@ def logs_page(request, tplname="core/logs_page.html"): @login_required def check_top_notifications(request): - """ - AJAX service to check for new top notifications to display. - """ + """AJAX service to check for new top notifications to display.""" notifications = signals.get_top_notifications.send( sender="top_notifications", include_all=True) notifications = reduce(