Back to index

python3.2  3.2.2
Public Member Functions
test.test_wsgiref.IntegrationTests Class Reference
Inheritance diagram for test.test_wsgiref.IntegrationTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_wsgiref.IntegrationTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def check_hello
def test_plain_hello
def test_validated_hello
def test_simple_validation_error
def test_wsgi_input
def test_bytes_validation

Detailed Description

Definition at line 129 of file test_wsgiref.py.


Member Function Documentation

def test.test_wsgiref.IntegrationTests.check_hello (   self,
  out,
  has_length = True 
)

Definition at line 131 of file test_wsgiref.py.

00131 
00132     def check_hello(self, out, has_length=True):
00133         self.assertEqual(out,
00134             ("HTTP/1.0 200 OK\r\n"
00135             "Server: WSGIServer/0.2 Python/"+sys.version.split()[0]+"\r\n"
00136             "Content-Type: text/plain\r\n"
00137             "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" +
00138             (has_length and  "Content-Length: 13\r\n" or "") +
00139             "\r\n"
00140             "Hello, world!").encode("iso-8859-1")
00141         )

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file test_wsgiref.py.

00178 
00179     def test_bytes_validation(self):
00180         def app(e, s):
00181             s("200 OK", [
00182                 ("Content-Type", "text/plain; charset=utf-8"),
00183                 ("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
00184                 ])
00185             return [b"data"]
00186         out, err = run_amock(validator(app))
00187         self.assertTrue(err.endswith('"GET / HTTP/1.0" 200 4\n'))
00188         ver = sys.version.split()[0].encode('ascii')
00189         self.assertEqual(
00190                 b"HTTP/1.0 200 OK\r\n"
00191                 b"Server: WSGIServer/0.2 Python/" + ver + b"\r\n"
00192                 b"Content-Type: text/plain; charset=utf-8\r\n"
00193                 b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n"
00194                 b"\r\n"
00195                 b"data",
00196                 out)
00197 
00198 
00199 

Here is the call graph for this function:

Definition at line 142 of file test_wsgiref.py.

00142 
00143     def test_plain_hello(self):
00144         out, err = run_amock()
00145         self.check_hello(out)

Here is the call graph for this function:

Definition at line 151 of file test_wsgiref.py.

00151 
00152     def test_simple_validation_error(self):
00153         def bad_app(environ,start_response):
00154             start_response("200 OK", ('Content-Type','text/plain'))
00155             return ["Hello, world!"]
00156         out, err = run_amock(validator(bad_app))
00157         self.assertTrue(out.endswith(
00158             b"A server error occurred.  Please contact the administrator."
00159         ))
00160         self.assertEqual(
00161             err.splitlines()[-2],
00162             "AssertionError: Headers (('Content-Type', 'text/plain')) must"
00163             " be of type list: <class 'tuple'>"
00164         )

Here is the call graph for this function:

Definition at line 146 of file test_wsgiref.py.

00146 
00147     def test_validated_hello(self):
00148         out, err = run_amock(validator(hello_app))
00149         # the middleware doesn't support len(), so content-length isn't there
00150         self.check_hello(out, has_length=False)

Here is the call graph for this function:

Definition at line 165 of file test_wsgiref.py.

00165 
00166     def test_wsgi_input(self):
00167         def bad_app(e,s):
00168             e["wsgi.input"].read()
00169             s("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
00170             return [b"data"]
00171         out, err = run_amock(validator(bad_app))
00172         self.assertTrue(out.endswith(
00173             b"A server error occurred.  Please contact the administrator."
00174         ))
00175         self.assertEqual(
00176             err.splitlines()[-2], "AssertionError"
00177         )

Here is the call graph for this function:


The documentation for this class was generated from the following file: