Beispiel #1
0
def test_to_curl_multiple_cookies():
    r = create_request(
        "GET",
        "http://foo.com",
        cookies=(
            acurl_ng._Cookie(False, "foo.com", True, "/", False, 0, "123",
                             "456").format(),
            acurl_ng._Cookie(False, "foo.com", True, "/", False, 0, "789",
                             "abc").format(),
        ),
    )
    assert r.to_curl(
    ) == "curl -X GET --cookie '123=456;789=abc' http://foo.com"
Beispiel #2
0
def test_request_cookies():
    session_mock = Mock()
    session_mock.get_cookie_list.return_value = ()
    r = create_request(
        "GET",
        "http://foo.com",
        cookies=(
            acurl_ng._Cookie(False, "foo.com", True, "/", False, 0, "foo",
                             "bar").format(),
            acurl_ng._Cookie(False, "foo.com", True, "/", False, 0,
                             "my_cookie", "my_value").format(),
        ),
    )
    assert "my_cookie" in r.cookies
    assert r.cookies["my_cookie"] == "my_value"
    assert "foo" in r.cookies
    assert r.cookies["foo"] == "bar"
Beispiel #3
0
def test_to_curl_cookies():
    r = create_request(
        "GET",
        "http://foo.com",
        cookies=(acurl_ng._Cookie(False, "foo.com", True, "/", False, 0, "123",
                                  "456").format(), ),
    )
    assert r.to_curl() == "curl -X GET --cookie 123=456 http://foo.com"
Beispiel #4
0
def test_cookie_not_expired():
    c = acurl_ng._Cookie(
        False,
        "foo.com",
        False,
        "/bar",
        False,
        time.time() + 200,
        "my_cookie",
        "my_value",
    )
    assert not c.has_expired
Beispiel #5
0
def test_to_curl_cookies_wrong_domain():
    # I'm not sure if this is a valid test case...Request objects should
    # probably only be constructed via Session.request, which always creates
    # cookies for the domain of the request.  So the case this is exercising
    # won't ever happen.
    r = create_request(
        "GET",
        "http://foo.com",
        # The domain doesn't match, the cookie should not be passed
        cookies=(acurl_ng._Cookie(False, "bar.com", True, "/", False, 0, "123",
                                  "456").format(), ),
    )
    assert r.to_curl() == "curl -X GET http://foo.com"
Beispiel #6
0
def test_cookie_zero_expiry():
    # FIXME: what's the right behavior here?
    c = acurl_ng._Cookie(False, "foo.com", False, "/bar", False, 0,
                         "my_cookie", "my_value")
    assert not c.has_expired
Beispiel #7
0
def test_cookie_format():
    c = acurl_ng._Cookie(False, "foo.com", False, "/bar", False, 0,
                         "my_cookie", "my_value")
    assert c.format() == b"foo.com\tFALSE\t/bar\tFALSE\t0\tmy_cookie\tmy_value"
Beispiel #8
0
def test_cookie_has_expired():
    c = acurl_ng._Cookie(False, "foo.com", False, "/bar", False, 1,
                         "my_cookie", "my_value")
    assert c.has_expired