~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to tests/regressiontests/requests/tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2008-11-15 19:15:33 UTC
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20081115191533-84v2zyjbmp1074ni
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
>>> from django.http import HttpRequest
3
 
>>> print repr(HttpRequest())
4
 
<HttpRequest
5
 
GET:{},
6
 
POST:{},
7
 
COOKIES:{},
8
 
META:{}>
9
 
 
10
 
>>> from django.core.handlers.wsgi import WSGIRequest
11
 
>>> print repr(WSGIRequest({'PATH_INFO': 'bogus', 'REQUEST_METHOD': 'bogus'}))
12
 
<WSGIRequest
13
 
GET:<QueryDict: {}>,
14
 
POST:<QueryDict: {}>,
15
 
COOKIES:{},
16
 
META:{...}>
17
 
 
18
 
>>> from django.core.handlers.modpython import ModPythonRequest
19
 
>>> class FakeModPythonRequest(ModPythonRequest):
20
 
...    def __init__(self, *args, **kwargs):
21
 
...        super(FakeModPythonRequest, self).__init__(*args, **kwargs)
22
 
...        self._get = self._post = self._meta = self._cookies = {}
23
 
>>> class Dummy:
24
 
...     def get_options(self):
25
 
...         return {}
26
 
>>> req = Dummy()
27
 
>>> req.uri = 'bogus'
28
 
>>> print repr(FakeModPythonRequest(req))
29
 
<ModPythonRequest
30
 
path:bogus,
31
 
GET:{},
32
 
POST:{},
33
 
COOKIES:{},
34
 
META:{}>
35
 
 
36
 
>>> from django.http import parse_cookie
37
 
>>> parse_cookie('invalid:key=true')
38
 
{}
39
 
 
40
 
>>> request = HttpRequest()
41
 
>>> print request.build_absolute_uri(location="https://www.example.com/asdf")
42
 
https://www.example.com/asdf
43
 
>>> request.get_host = lambda: 'www.example.com'
44
 
>>> request.path = ''
45
 
>>> print request.build_absolute_uri(location="/path/with:colons")
46
 
http://www.example.com/path/with:colons
47
 
"""