forked from csernazs/pytest-httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_querystring.py
More file actions
38 lines (30 loc) · 1.35 KB
/
test_querystring.py
File metadata and controls
38 lines (30 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
from pytest_httpserver import HTTPServer
def test_querystring_str(httpserver: HTTPServer):
httpserver.expect_request("/foobar", query_string="foo=bar", method="GET").respond_with_data(
"example_response"
)
response = requests.get(httpserver.url_for("/foobar?foo=bar"))
httpserver.check_assertions()
assert response.text == "example_response"
assert response.status_code == 200
def test_querystring_bytes(httpserver: HTTPServer):
httpserver.expect_request("/foobar", query_string=b"foo=bar", method="GET").respond_with_data(
"example_response"
)
response = requests.get(httpserver.url_for("/foobar?foo=bar"))
httpserver.check_assertions()
assert response.text == "example_response"
assert response.status_code == 200
def test_querystring_dict(httpserver: HTTPServer):
httpserver.expect_request("/foobar", query_string={"k1": "v1", "k2": "v2"}, method="GET").respond_with_data(
"example_response"
)
response = requests.get(httpserver.url_for("/foobar?k1=v1&k2=v2"))
httpserver.check_assertions()
assert response.text == "example_response"
assert response.status_code == 200
response = requests.get(httpserver.url_for("/foobar?k2=v2&k1=v1"))
httpserver.check_assertions()
assert response.text == "example_response"
assert response.status_code == 200