Exemplo n.º 1
0
 def test_display_to_user(self):
     request = self.factory.get('/')
     request.user = self.user
     with mock.patch('net_promoter_score.settings.NPS_DISPLAY_FUNCTION', lambda r: True):
         self.assertTrue(show_nps(request))
     with mock.patch('net_promoter_score.settings.NPS_DISPLAY_FUNCTION', lambda r: False):
         self.assertFalse(show_nps(request))
Exemplo n.º 2
0
 def process_request(self, request):
     # force instantiation of the request.user SimpleLazyObject
     assert hasattr(request, 'user'), (
         "Missing middleware: "
         "'django.contrib.auth.middleware.AuthenticationMiddleware'"
     )
     if request.user.is_authenticated():
         request.show_nps = show_nps(request)
     else:
         request.show_nps = False
     return None