2012-07-30 08:58:59 +00:00
|
|
|
import requests
|
2016-02-16 19:59:33 +00:00
|
|
|
from pathod import test
|
2012-07-30 08:58:59 +00:00
|
|
|
|
2015-05-30 00:03:13 +00:00
|
|
|
|
2012-08-23 00:37:02 +00:00
|
|
|
def test_simple():
|
2012-07-30 08:58:59 +00:00
|
|
|
"""
|
2012-08-23 00:37:02 +00:00
|
|
|
Testing the requests module with
|
2012-07-30 08:58:59 +00:00
|
|
|
a pathod context manager.
|
|
|
|
"""
|
2012-08-23 00:37:02 +00:00
|
|
|
# Start pathod in a separate thread
|
|
|
|
with test.Daemon() as d:
|
|
|
|
# Get a URL for a pathod spec
|
|
|
|
url = d.p("200:b@100")
|
|
|
|
# ... and request it
|
|
|
|
r = requests.put(url)
|
2012-07-30 08:58:59 +00:00
|
|
|
|
2012-08-23 00:37:02 +00:00
|
|
|
# Check the returned data
|
|
|
|
assert r.status_code == 200
|
2015-09-21 21:03:45 +00:00
|
|
|
assert len(r.content) == 100
|
2012-07-30 08:58:59 +00:00
|
|
|
|
2012-08-23 00:37:02 +00:00
|
|
|
# Check pathod's internal log
|
|
|
|
log = d.last_log()["request"]
|
|
|
|
assert log["method"] == "PUT"
|