コード例 #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)
コード例 #2
0
ファイル: request.py プロジェクト: howaryoo/nefertari
    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)
コード例 #3
0
ファイル: test_utils.py プロジェクト: timgates42/nefertari
 def test_json_dumps_encoder(self, mock_json):
     utils.json_dumps('foo', 'enc')
     mock_json.dumps.assert_called_once_with('foo', cls='enc')
コード例 #4
0
ファイル: test_utils.py プロジェクト: timgates42/nefertari
 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())
コード例 #5
0
ファイル: test_utils.py プロジェクト: karthikmm/nefertari
 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)
コード例 #6
0
ファイル: test_utils.py プロジェクト: karthikmm/nefertari
 def test_json_dumps_encoder(self, mock_json):
     utils.json_dumps('foo', 'enc')
     mock_json.dumps.assert_called_once_with('foo', cls='enc')
コード例 #7
0
ファイル: test_utils.py プロジェクト: mbijon/nefertari
 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())