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)
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)
def test_json_dumps_encoder(self, mock_json): utils.json_dumps('foo', 'enc') mock_json.dumps.assert_called_once_with('foo', cls='enc')
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())
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)