예제 #1
0
 def test_httperror_with_Exception(self):
     from linotp.lib.reply import _get_httperror_from_params
     # Raising exceptions on attribute access
     prop_mock = PropertyMock(side_effect=Exception("Random exception"))
     type(self.pylons_request).params = prop_mock
     self.pylons_request.query_string = 'httperror=555'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, None)
예제 #2
0
 def test_httperror_set_and_empty(self):
     from linotp.lib.reply import _get_httperror_from_params
     self.pylons_request.params = {
         'httperror': '',
         }
     self.pylons_request.query_string = 'httperror'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, '500')
예제 #3
0
 def test_httperror_with_Exception(self):
     from linotp.lib.reply import _get_httperror_from_params
     # Raising exceptions on attribute access
     prop_mock = PropertyMock(side_effect=Exception("Random exception"))
     type(self.pylons_request).params = prop_mock
     self.pylons_request.query_string = 'httperror=555'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, None)
예제 #4
0
 def test_httperror_set_and_empty(self):
     from linotp.lib.reply import _get_httperror_from_params
     self.pylons_request.params = {
         'httperror': '',
         }
     self.pylons_request.query_string = 'httperror'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, '500')
예제 #5
0
 def test_httperror_with_UnicodeDecodeError_and_mult_param(self):
     from linotp.lib.reply import _get_httperror_from_params
     # Raising exceptions on attribute access
     prop_mock = PropertyMock(side_effect=UnicodeDecodeError(
         'utf8', '\xc0', 0, 1, 'invalid start byte'))
     type(self.pylons_request).params = prop_mock
     self.pylons_request.query_string = 'httperror=555&httperror=777'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, '777')
예제 #6
0
    def test_httperror_with_Exception(self, monkeypatch):
        class fake_current_app(object):
            def getRequestParams(self):
                raise Exception("Random exception")

        monkeypatch.setattr(reply, 'current_app', fake_current_app())

        with flask.current_app.test_request_context('/?httperror=555'):
            httperror = _get_httperror_from_params(None)
            assert httperror is None
예제 #7
0
 def test_httperror_with_UnicodeDecodeError_and_mult_param(self):
     from linotp.lib.reply import _get_httperror_from_params
     # Raising exceptions on attribute access
     prop_mock = PropertyMock(
         side_effect=UnicodeDecodeError(
             'utf8',
             '\xc0',
             0,
             1,
             'invalid start byte'
             )
         )
     type(self.pylons_request).params = prop_mock
     self.pylons_request.query_string = 'httperror=555&httperror=777'
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, '777')
예제 #8
0
 def test_httperror_unset(self):
     from linotp.lib.reply import _get_httperror_from_params
     self.pylons_request.params = {}
     self.pylons_request.query_string = ''
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, None)
예제 #9
0
 def test_httperror_unset(self):
     from linotp.lib.reply import _get_httperror_from_params
     self.pylons_request.params = {}
     self.pylons_request.query_string = ''
     httperror = _get_httperror_from_params(self.pylons_request)
     self.assertEquals(httperror, None)
예제 #10
0
 def test_httperror_with_UnicodeDecodeError_and_mult_param(self):
     # Raising exceptions on attribute access
     with flask.current_app.test_request_context(
             '/?httperror=555&httperror=777'):
         httperror = _get_httperror_from_params(None)
         assert httperror == '777'
예제 #11
0
 def test_httperror_with_UnicodeDecodeError(self):
     with flask.current_app.test_request_context('/?httperror=555'):
         httperror = _get_httperror_from_params(None)
         assert httperror == '555'
예제 #12
0
 def test_httperror_from_params(self, app, querystring, result):
     with app.test_request_context(querystring):
         httperror = _get_httperror_from_params(None)
         assert httperror == result