From 4feb0c7a013169c3ddd510d015f6df6566c34db8 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 29 Mar 2017 20:10:39 +0530 Subject: [PATCH] Complete tests and remove duplicate context information --- plinth/tests/test_context_processors.py | 6 +++++- plinth/views.py | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plinth/tests/test_context_processors.py b/plinth/tests/test_context_processors.py index e58ffd623..b1b25391b 100644 --- a/plinth/tests/test_context_processors.py +++ b/plinth/tests/test_context_processors.py @@ -20,7 +20,6 @@ Test module for Plinth's custom context processors. """ from unittest.mock import Mock -from django.contrib.auth.models import User from django.http import HttpRequest from django.test import TestCase @@ -55,6 +54,11 @@ class ContextProcessorsTestCase(TestCase): self.assertIsNotNone(urls) self.assertEqual(['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'], urls) + self.assertTrue(response['user_is_admin']) + request.user.groups.filter().exists = Mock(return_value=False) + response = cp.common(request) + self.assertFalse(response['user_is_admin']) + def test_common_border_conditions(self): """Verify that the common() function works for border conditions.""" request = HttpRequest() diff --git a/plinth/views.py b/plinth/views.py index 31b2dfc52..489550d81 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -30,7 +30,6 @@ import time from . import forms, frontpage import plinth -from plinth.utils import is_user_admin @public @@ -51,8 +50,7 @@ def index(request): 'selected_id': selection, 'details': details, 'details_label': details_label, - 'configure_url': configure_url, - 'user_is_admin': is_user_admin(request.user)}) + 'configure_url': configure_url}) class ServiceView(FormView):