예제 #1
0
def test_cookies():
    sender = Sender(middleware=[])
    sender.get(
        "http://example.com",
        headers={"x-custom": "hello"},
        params={"v": "1.0"},
        cookies={"clientSession": "session"},
    )
예제 #2
0
def test_for_requests_with_params():
    sender = Sender(middleware=[])
    sender.get(
        "http://example.com",
        headers={"x-custom": "hello"},
        params={"v": "1.0"},
        data="some-data",
    )
def test_default_stack(snapshot):
    logger = DummyLogger()
    sender = 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))
예제 #4
0
def test_namespace():
    expected = 'formation-namespace'
    sender = Sender(middleware=[
        assert_context(expected),
        context(env='env', namespace=expected),
    ])
    sender.get("http://example.com")
    sender = Sender(middleware=[
        assert_context(expected),
        context(env='env', namespace=expected),
    ])
예제 #5
0
def test_accept():
    sender = Sender(middleware=[accept("application/json")])
    sender.get("http://example.com",
               headers={"x-custom": "hello"},
               params={"v": "1.0"})
예제 #6
0
def test_ua():
    sender = Sender(middleware=[ua("foobar/1.0.0")])
    sender.get("http://example.com",
               headers={"x-custom": "hello"},
               params={"v": "1.0"})
예제 #7
0
def test_for_requests():
    sender = Sender(middleware=[])
    sender.get("http://example.com")