예제 #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 = 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'"
        )
예제 #5
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'"
        )
예제 #6
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'"
        )
예제 #7
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 @-"
        )
예제 #8
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'"
        )