def test_1000(self): """mock_api.post(): Echoes the request""" mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) response = requests.post(d1_test.d1_test_case.MOCK_MN_BASE_URL + '/v1/post') body_dict = response.json() d1_test.sample.assert_equals(body_dict, 'post_request_echo')
def _post(self, query_dict, header_dict, body): mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) s = session.Session( d1_test.d1_test_case.MOCK_MN_BASE_URL, query={ 'default_query': 'test', } ) return s.POST(['post'], query=query_dict, headers=header_dict, data=body)
def test_1050(self): """Query params passed to Session() and individual POST are correctly combined""" mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) body_bytes = b'test_body' query_dict = {'abcd': '1234', 'efgh': '5678'} header_dict = {'ijkl': '9876', 'mnop': '5432'} response = self._post(query_dict, header_dict, body_bytes) r_dict = response.json() d1_test.sample.assert_equals(r_dict, 'post_roundtrip_query')
def test_1050(self): """Query params passed to Session() and individual POST are combined""" mock_post.add_callback(d1_test.d1_test_case.MOCK_BASE_URL) body_str = 'test_body' query_dict = {'abcd': '1234', 'efgh': '5678'} header_dict = {'ijkl': '9876', 'mnop': '5432'} response = self._post(query_dict, header_dict, body_str) r_dict = response.json() assert base64.b64decode(r_dict['body_str']) == body_str assert 'abcd' in r_dict['query_dict'] assert r_dict['query_dict']['abcd'] == ['1234'] assert 'default_query' in r_dict['query_dict'] assert r_dict['query_dict']['default_query'] == ['test']
def test_1000(self, mn_client_v1_v2): """mock_api.post(): Echoes the request""" mock_post.add_callback(d1_test.d1_test_case.MOCK_BASE_URL) response = requests.post(d1_test.d1_test_case.MOCK_BASE_URL + '/v1/post') body_dict = response.json() expected_dict = { u'body_str': u'', u'query_dict': {}, u'header_dict': { u'Connection': u'keep-alive', u'Content-Length': u'0', u'Accept': u'*/*', u'Accept-Encoding': u'gzip, deflate' } } assert 'User-Agent' in body_dict['header_dict'] del body_dict['header_dict']['User-Agent'] assert body_dict == expected_dict
def _post_fields(self, fields_dict): mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) s = session.Session(d1_test.d1_test_case.MOCK_MN_BASE_URL) return s.POST(['post'], fields=fields_dict)