예제 #1
0
    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'"
        )
예제 #2
0
    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 @-"
        )
예제 #3
0
    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'"
        )
예제 #4
0
    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'"
        )
예제 #5
0
    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'"
        )
예제 #6
0
    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'"
        )
예제 #7
0
    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'"
        )
예제 #8
0
    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 @-"
        )
예제 #9
0
    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))
예제 #10
0
    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))
예제 #11
0
    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))
예제 #12
0
    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))