Files
deb-python-falcon/tests/test_req_vars.py
Jamie Painter a905ea95f1 Merge remote-tracking branch 'upstream/master' into testing_refactor
Conflicts:
	tests/test_headers.py
2013-02-06 09:28:37 -05:00

47 lines
1.5 KiB
Python

from falcon.request import Request
import falcon.testing as testing
class TestReqVars(testing.TestSuite):
def prepare(self):
qs = '?marker=deadbeef&limit=10'
headers = {
'Content-Type': 'text/plain',
'Content-Length': '4829'
}
self.req = Request(testing.create_environ(script='/test',
path='/hello',
query_string=qs,
headers=headers))
def test_reconstruct_url(self):
req = self.req
scheme = req.protocol
host = req.get_header('host')
app = req.app
path = req.path
query_string = req.query_string
expected_url = 'http://falconer/test/hello?marker=deadbeef&limit=10'
actual_url = ''.join([scheme, '://', host, app, path, query_string])
self.assertEquals(actual_url, expected_url)
def test_method(self):
self.assertEquals(self.req.method, 'GET')
self.req = Request(testing.create_environ(path='', method='HEAD'))
self.assertEquals(self.req.method, 'HEAD')
def test_empty_path(self):
self.req = Request(testing.create_environ(path=''))
self.assertEquals(self.req.path, '/')
def test_content_type(self):
self.assertEquals(self.req.get_header('content-type'), 'text/plain')
def test_content_length(self):
self.assertEquals(self.req.get_header('content-length'), '4829')