Mercurial > hg > FileServer
comparison tests/doctest.txt @ 12:8127dde8da22
fix slashing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 29 Feb 2012 15:41:01 -0800 |
parents | 1aaf2ba89b30 |
children | c8520774ddc9 |
comparison
equal
deleted
inserted
replaced
11:1aaf2ba89b30 | 12:8127dde8da22 |
---|---|
3 | 3 |
4 The obligatory imports:: | 4 The obligatory imports:: |
5 | 5 |
6 >>> import fileserver | 6 >>> import fileserver |
7 >>> import os | 7 >>> import os |
8 >>> import urlparse | |
8 >>> from paste.fixture import TestApp | 9 >>> from paste.fixture import TestApp |
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') |
51 404 | 52 404 |
52 | 53 |
53 Ensure you can get resources from subdirectories:: | 54 Ensure you can get resources from subdirectories:: |
54 | 55 |
55 >>> response = testapp.get('/foo') | 56 >>> response = testapp.get('/foo') |
57 >>> response.status # 301 Moved Permanently | |
58 301 | |
59 >>> location = response.header_dict['location'] | |
60 >>> shema, netloc, path, query, fragment = urlparse.urlsplit(location) | |
61 >>> path | |
62 '/foo/' | |
63 >>> response = testapp.get('/foo/') | |
56 >>> response.status | 64 >>> response.status |
65 200 | |
66 >>> 'bar.txt' in response.body | |
67 True | |
57 | 68 |
58 Ensure you can't get to non-allowed resources:: | 69 Ensure you can't get to non-allowed resources:: |
59 | 70 |
60 >>> response = testapp.get('/../exampleBADBADBAD') | 71 >>> response = testapp.get('/../exampleBADBADBAD') |