Mercurial > hg > simpypi
annotate tests/doctest.txt @ 47:cb24b5265557
clean out tmpdir
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 01 Mar 2012 13:42:42 -0800 |
parents | d9bc2a586ed4 |
children | ca456e08924f |
rev | line source |
---|---|
7 | 1 Test simpypi |
2 ============ | |
6 | 3 |
4 The obligatory imports:: | |
5 | |
33
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
6 >>> import os |
44 | 7 >>> import shutil |
6 | 8 >>> import simpypi |
33
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
9 >>> from paste.fixture import TestApp |
6 | 10 |
33
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
11 The directory is initially empty:: |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
12 |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
13 >>> os.listdir(directory) |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
14 [] |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
15 |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
16 Make a test application:: |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
17 |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
18 >>> app = simpypi.SimPyPI(directory) |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
19 >>> testapp = TestApp(app) |
36
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
20 |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
21 Upload a package:: |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
22 |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
23 >>> field = 'package' |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
24 >>> filename = 'HelloWorld-0.0.tar.gz' |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
25 >>> contents = file(os.path.join(here, filename)).read() |
37
1bdece293671
* fix calling signature in test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
26 >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) |
43
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
27 |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
28 Ensure that package is in the right place:: |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
29 |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
30 >>> os.listdir(directory) |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
31 ['HelloWorld'] |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
32 >>> os.listdir(os.path.join(directory, 'HelloWorld')) |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
33 ['HelloWorld-0.0.tar.gz'] |
47 | 34 |
35 Upload the same package but with the wrong name:: | |
36 | |
37 >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) | |
38 >>> os.listdir(directory) | |
39 [] |