Mercurial > hg > FileServer
annotate tests/test_fileapp.txt @ 29:d8b73d9b679d
separate testing fileapp to its own doctest file
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 05 Mar 2012 13:27:06 -0800 |
parents | |
children | 52103702a732 |
rev | line source |
---|---|
29
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 Test FileApp |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 ============ |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 The obligatory imports:: |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 >>> import fileserver |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 >>> import os |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 >>> from paste.fixture import TestApp |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
10 Make a single file server:: |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 >>> filename = os.path.join(here, 'example', 'helloworld.txt') |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
13 >>> os.path.exists(filename) |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
14 True |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
15 >>> app = fileserver.FileApp(filename) |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
16 >>> testapp = TestApp(app) |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
17 >>> response = testapp.get('/') |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
18 >>> response.status |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
19 200 |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
20 >>> response.body == file(filename).read() |
d8b73d9b679d
separate testing fileapp to its own doctest file
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
21 True |