Пример #1
0
def test_parse_curl_with_binary_data():
    runcurl.parse(
        """curl 'https://pypi.python.org/pypi/runcurl' --data-binary 'this is just some data'"""
    ).should.equal("""requests.post("https://pypi.python.org/pypi/runcurl",
    data='this is just some data',
    headers={},
    cookies={},
)""")
Пример #2
0
def test_basic_headers():
    runcurl.parse(
        "curl 'https://pypi.python.org/pypi/runcurl' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8'"
    ).should.equal("""requests.get("https://pypi.python.org/pypi/runcurl",
    headers={
        "Accept-Encoding": "gzip,deflate,sdch",
        "Accept-Language": "en-US,en;q=0.8",
    },
    cookies={},
)""")
Пример #3
0
def test_cookies_lowercase():
    runcurl.parse(
        "curl 'https://pypi.python.org/pypi/runcurl' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'cookie: foo=bar; baz=baz2'"
    ).should.equal("""requests.get("https://pypi.python.org/pypi/runcurl",
    headers={
        "Accept-Encoding": "gzip,deflate,sdch",
    },
    cookies={
        "baz": "baz2",
        "foo": "bar",
    },
)""")
Пример #4
0
def test_post():
    runcurl.parse(
        """curl 'https://pypi.python.org/pypi/runcurl' --data '[{"evt":"newsletter.show","properties":{"newsletter_type":"userprofile"},"now":1396219192277,"ab":{"welcome_email":{"v":"2","g":2}}}]' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Cookie: foo=bar; baz=baz2'"""
    ).should.equal("""requests.post("https://pypi.python.org/pypi/runcurl",
    data='[{"evt":"newsletter.show","properties":{"newsletter_type":"userprofile"},"now":1396219192277,"ab":{"welcome_email":{"v":"2","g":2}}}]',
    headers={
        "Accept-Encoding": "gzip,deflate,sdch",
    },
    cookies={
        "baz": "baz2",
        "foo": "bar",
    },
)""")
Пример #5
0
def test_post_with_dict_data():
    runcurl.parse(
        """curl 'https://pypi.python.org/pypi/runcurl' --data '{"evt":"newsletter.show","properties":{"newsletter_type":"userprofile"}}' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Cookie: foo=bar; baz=baz2'"""
    ).should.equal("""requests.post("https://pypi.python.org/pypi/runcurl",
    data={
        "evt": "newsletter.show",
        "properties": {
            "newsletter_type": "userprofile",
        },
    },
    headers={
        "Accept-Encoding": "gzip,deflate,sdch",
    },
    cookies={
        "baz": "baz2",
        "foo": "bar",
    },
)""")
Пример #6
0
def test_basic_get():
    runcurl.parse("curl 'https://pypi.python.org/pypi/runcurl'").should.equal(
        """requests.get("https://pypi.python.org/pypi/runcurl",
        headers={},
        cookies={},
    )""")