Exemple #1
0
    def post(self, path='', data={}, **kw):
        url = self.prepare_url(path)
        log.debug('%s, kwargs:%.512s', url, data)
        try:
            resp = requests.post(url,
                                 data=json_dumps(data),
                                 headers={'content-type': 'application/json'},
                                 **kw)
            if not resp.ok:
                raise exception_response(**resp.json())

            return pyramid_resp(resp)
        except requests.ConnectionError as e:
            raise JHTTPServerError('Server is down? %s' % e)
Exemple #2
0
    def post(self, path='', data={}, **kw):
        url = self.prepare_url(path)
        log.debug('%s, kwargs:%.512s', url, data)
        try:
            resp = requests.post(
                url, data=json_dumps(data),
                headers={'content-type': 'application/json'},
                **kw)
            if not resp.ok:
                raise exception_response(**resp.json())

            return pyramid_resp(resp)
        except requests.ConnectionError as e:
            raise JHTTPServerError('Server is down? %s' % e)
Exemple #3
0
 def test_json_dumps_encoder(self, mock_json):
     utils.json_dumps('foo', 'enc')
     mock_json.dumps.assert_called_once_with('foo', cls='enc')
Exemple #4
0
 def test_json_dumps(self, mock_json, mock_get):
     utils.json_dumps('foo')
     mock_get.assert_called_once_with()
     mock_json.dumps.assert_called_once_with('foo', cls=mock_get())
Exemple #5
0
 def test_json_dumps(self, mock_json):
     from nefertari.renderers import _JSONEncoder
     utils.json_dumps('foo')
     mock_json.dumps.assert_called_once_with('foo', cls=_JSONEncoder)
Exemple #6
0
 def test_json_dumps_encoder(self, mock_json):
     utils.json_dumps('foo', 'enc')
     mock_json.dumps.assert_called_once_with('foo', cls='enc')
Exemple #7
0
 def test_json_dumps(self, mock_json, mock_get):
     utils.json_dumps('foo')
     mock_get.assert_called_once_with()
     mock_json.dumps.assert_called_once_with('foo', cls=mock_get())