def test_curl_string_put(self): request = make_put_request('http://test.com/path', data='DATA', content_type='text/plain') self.assertEqual( request_to_curl_string(request), "curl -X PUT 'http://test.com/path' -H 'Content-Length: 4' -H 'Content-Type: text/plain' --data 'DATA'" )
def test_curl_string_binary(self): request = make_post_request('http://test.com/path', data=u'тест', content_type='text/plain') self.assertEqual( request_to_curl_string(request), "echo -e '\\xd1\\x82\\xd0\\xb5\\xd1\\x81\\xd1\\x82' | " "curl -X POST 'http://test.com/path' -H 'Content-Length: 4' -H 'Content-Type: text/plain' --data-binary @-" )
def test_curl_string_post(self): request = make_post_request('http://test.com/path', data={'param': 'value'}) self.assertEqual( request_to_curl_string(request), "curl -X POST 'http://test.com/path' -H 'Content-Length: 11' " "-H 'Content-Type: application/x-www-form-urlencoded' --data 'param=value'" )
def test_curl_string_get(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), '/path', 'test', data={'param': 'value'}, headers={'Accept': media_types.APPLICATION_JSON}).make_request() self.assertEqual( request_to_curl_string(request), "curl -X GET 'http://test.com/path?param=value' -H 'Accept: application/json'" )
def test_curl_string_put(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), '/path', 'test', data='DATA', method='PUT', content_type=media_types.TEXT_PLAIN).make_request() self.assertEqual( request_to_curl_string(request), "curl -X PUT 'http://test.com/path' -H 'Content-Length: 4' -H 'Content-Type: text/plain' --data 'DATA'" )
def test_curl_string_post(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), '/path', 'test', data={'param': 'value'}, method='POST').make_request() self.assertEqual( request_to_curl_string(request), "curl -X POST 'http://test.com/path' -H 'Content-Length: 11' " "-H 'Content-Type: application/x-www-form-urlencoded' --data 'param=value'" )
def test_curl_string_get(self): request = make_get_request( 'http://test.com/path', data={'param': 'value'}, headers={'Accept': 'application/json'} ) self.assertEqual( request_to_curl_string(request), "curl -X GET 'http://test.com/path?param=value' -H 'Accept: application/json'" )
def test_curl_string_binary(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), '/path', 'test', data='тест', method='POST', content_type=media_types.TEXT_PLAIN).make_request() self.assertEqual( request_to_curl_string(request), "echo -e '\\xd1\\x82\\xd0\\xb5\\xd1\\x81\\xd1\\x82' | " "curl -X POST 'http://test.com/path' -H 'Content-Length: 8' -H 'Content-Type: text/plain' --data-binary @-" )
def test_curl_string_put(self): request = BalancedHttpRequest( 'http://test.com', Upstream.get_single_host_upstream(), 'test', '/path', 'test', data='DATA', method='PUT', content_type=media_types.TEXT_PLAIN).make_request() self.assertEqual( request_to_curl_string(request), "curl -X PUT 'http://test.com/path' -H 'Content-Length: 4' -H 'Content-Type: text/plain' " "-H '{}: test' --data 'DATA'".format(USER_AGENT_HEADER))
def test_curl_string_binary(self): request = BalancedHttpRequest( 'http://test.com', Upstream.get_single_host_upstream(), 'test', '/path', 'test', data='тест', method='POST', content_type=media_types.TEXT_PLAIN).make_request() self.assertEqual( request_to_curl_string(request), "echo -e '\\xd1\\x82\\xd0\\xb5\\xd1\\x81\\xd1\\x82' | " "curl -X POST 'http://test.com/path' -H 'Content-Length: 8' -H 'Content-Type: text/plain' " "-H '{}: test' --data-binary @-".format(USER_AGENT_HEADER))
def test_curl_string_post(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), 'test', '/path', 'test', data={ 'param': 'value' }, method='POST').make_request() self.assertEqual( request_to_curl_string(request), "curl -X POST 'http://test.com/path' -H 'Content-Length: 11' " "-H 'Content-Type: application/x-www-form-urlencoded' " "-H '{}: test' --data 'param=value'".format(USER_AGENT_HEADER))
def test_curl_string_get(self): request = BalancedHttpRequest('http://test.com', Upstream.get_single_host_upstream(), 'test', '/path', 'test', data={ 'param': 'value' }, headers={ 'Accept': media_types.APPLICATION_JSON }).make_request() self.assertEqual( request_to_curl_string(request), "curl -X GET 'http://test.com/path?param=value' " "-H 'Accept: application/json' -H '{}: test' -H '{}: 2000'".format( USER_AGENT_HEADER, OUTER_TIMEOUT_MS_HEADER))