Example #1
0
def test_for_requests_with_params():
    sender = build_sender(middleware=[])
    sender(
        "get",
        "http://example.com",
        headers={"x-custom": "hello"},
        params={"v": "1.0"},
        data="some-data",
    )
Example #2
0
def test_default_stack(snapshot):
    logger = DummyLogger()
    sender = build_sender(middleware=get_test_stack(logger))
    sender("get", "http://example.com")
    snapshot.assert_match(
        list(
            map(
                lambda arr: [
                    arr[0],
                    arr[1],
                    sanitize(update_in(arr[2], ["headers"], sanitize)),
                    sanitize(arr[3]),
                ],
                logger.messages,
            )))
    snapshot.assert_match(sanitize(logger.context))
Example #3
0
def test_accept():
    sender = build_sender(middleware=[accept("application/json")])
    sender(
        "get", "http://example.com", headers={"x-custom": "hello"}, params={"v": "1.0"}
    )
Example #4
0
def test_ua():
    sender = build_sender(middleware=[ua("foobar/1.0.0")])
    sender(
        "get", "http://example.com", headers={"x-custom": "hello"}, params={"v": "1.0"}
    )
Example #5
0
def test_for_requests():
    sender = build_sender(middleware=[])
    sender("get", "http://example.com")
Example #6
0
def test_cookies():
    sender = build_sender(middleware=[])
    sender(
        "get", "http://example.com", headers={"x-custom": "hello"}, params={"v": "1.0"}, cookies={"clientSession": "session"}
    )