Exemplo n.º 1
0
 def assert_fetch_raises(self, view_name, args=None, kwargs=None):
     """Assert view raises error when api-key is missing and in debug mode."""
     with self.assertRaises(ImproperlyConfigured):
         response_from_view(view_name, args=args, kwargs=kwargs)
Exemplo n.º 2
0
 def assert_raises_when_not_debugging(self, view_name, args=None, kwargs=None):
     """Assert view raises error when api-key is missing and in debug mode."""
     with mock_fetch_with_no_api_key(), use_debug_mode(False):
         with self.assertRaises(ImproperlyConfigured):
             response_from_view(view_name, args=args, kwargs=kwargs)
Exemplo n.º 3
0
 def assert_fetch_redirects(self, view_name, args=None, kwargs=None):
     """Assert view redirects to error page when api-key is missing and in debug mode."""
     response = response_from_view(view_name, args=args, kwargs=kwargs)
     self.assertRedirects(response, reverse('openstates:api-key-required'))
Exemplo n.º 4
0
 def assert_redirect_when_debugging(self, view_name, args=None, kwargs=None):
     """Assert view redirects to error page when api-key is missing and in debug mode."""
     with mock_fetch_with_no_api_key(), use_debug_mode(True):
         response = response_from_view(view_name, args=args, kwargs=kwargs)
         self.assertRedirects(response, reverse('openstates:api-key-required'))