Mercurial > hg > FileServer
comparison tests/test_fileapp.txt @ 30:52103702a732
figured out the magical code for doctest.ELLIPSIS
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 05 Mar 2012 13:40:15 -0800 |
parents | d8b73d9b679d |
children | f00fcf6d9f1d |
comparison
equal
deleted
inserted
replaced
29:d8b73d9b679d | 30:52103702a732 |
---|---|
4 The obligatory imports:: | 4 The obligatory imports:: |
5 | 5 |
6 >>> import fileserver | 6 >>> import fileserver |
7 >>> import os | 7 >>> import os |
8 >>> from paste.fixture import TestApp | 8 >>> from paste.fixture import TestApp |
9 >>> from webob import Request | |
9 | 10 |
10 Make a single file server:: | 11 Make a single file server:: |
11 | 12 |
12 >>> filename = os.path.join(here, 'example', 'helloworld.txt') | 13 >>> filename = os.path.join(here, 'example', 'helloworld.txt') |
13 >>> os.path.exists(filename) | 14 >>> os.path.exists(filename) |
17 >>> response = testapp.get('/') | 18 >>> response = testapp.get('/') |
18 >>> response.status | 19 >>> response.status |
19 200 | 20 200 |
20 >>> response.body == file(filename).read() | 21 >>> response.body == file(filename).read() |
21 True | 22 True |
23 | |
24 With conditional_response on, and with last_modified and etag set, we | |
25 can do conditional requests:: | |
26 | |
27 >>> content_length = os.path.getsize(filename) | |
28 >>> content_length # don't ask me why the 'L' | |
29 6L | |
30 >>> req = Request.blank('/') | |
31 >>> res = req.get_response(app) | |
32 >>> print res # doctest:+ELLIPSIS | |
33 200 OK | |
34 Content-Type: text/plain; charset=UTF-8 | |
35 Content-Length: 6 | |
36 Last-Modified: ... GMT | |
37 ETag: ...-... | |
38 <BLANKLINE> | |
39 hello | |
40 <BLANKLINE> |