Mercurial > hg > simpypi
annotate tests/doctest.txt @ 51:6a8071eab89e
add in smokescreen pkginfo tests
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 01 Mar 2012 14:33:50 -0800 |
parents | e4a97d6f2811 |
children | 59368c0bbd8d |
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 |
51
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
7 >>> import pkginfo |
44 | 8 >>> import shutil |
6 | 9 >>> import simpypi |
50
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
10 >>> import tempfile |
33
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
11 >>> from paste.fixture import TestApp |
6 | 12 |
33
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
13 The directory is initially empty:: |
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 >>> os.listdir(directory) |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
16 [] |
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 Make a test application:: |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
19 |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
20 >>> app = simpypi.SimPyPI(directory) |
058182b7b309
note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents:
8
diff
changeset
|
21 >>> testapp = TestApp(app) |
36
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 Upload a package:: |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
24 |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
25 >>> field = 'package' |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
26 >>> filename = 'HelloWorld-0.0.tar.gz' |
a02d08627d9c
stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
27 >>> contents = file(os.path.join(here, filename)).read() |
37
1bdece293671
* fix calling signature in test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
28 >>> 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
|
29 |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
30 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
|
31 |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
32 >>> os.listdir(directory) |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
33 ['HelloWorld'] |
089d5650d7e2
check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
34 >>> 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
|
35 ['HelloWorld-0.0.tar.gz'] |
47 | 36 |
50
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
37 Ensure the package is what you expect it to be:: |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
38 |
51
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
39 >>> path = os.path.join(directory, 'HelloWorld', 'HelloWorld-0.0.tar.gz') |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
40 >>> sdist = pkginfo.sdist.SDist(path) |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
41 >>> sdist.name |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
42 'HelloWorld' |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
43 >>> sdist.version |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
44 '0.0' |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
45 |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
46 Install the package and inspect the installation:: |
6a8071eab89e
add in smokescreen pkginfo tests
Jeff Hammel <jhammel@mozilla.com>
parents:
50
diff
changeset
|
47 |
50
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
48 >>> tmpdir = tempfile.mkdtemp() |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
49 >>> shutil.rmtree(tmpdir) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
50 |
47 | 51 Upload the same package but with the wrong name:: |
52 | |
53 >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) | |
54 >>> os.listdir(directory) | |
55 [] | |
49
ca456e08924f
add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents:
47
diff
changeset
|
56 >>> response = testapp.post('/', upload_files=[(field, 'MisleadingName.tar.gz', contents)]) |
ca456e08924f
add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents:
47
diff
changeset
|
57 >>> os.listdir(directory) |
ca456e08924f
add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents:
47
diff
changeset
|
58 ['HelloWorld'] |
ca456e08924f
add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents:
47
diff
changeset
|
59 >>> os.listdir(os.path.join(directory, 'HelloWorld')) |
ca456e08924f
add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents:
47
diff
changeset
|
60 ['HelloWorld-0.0.tar.gz'] |
50
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
61 >>> shutil.rmtree(os.path.join(directory, 'HelloWorld')) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
62 >>> os.listdir(directory) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
63 [] |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
64 >>> filename = 'MisleadingFilename.tar.gz' |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
65 >>> contents = file(os.path.join(here, filename)).read() |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
66 >>> response = testapp.post('/', upload_files=[(field, filename, contents)]) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
67 >>> os.listdir(directory) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
68 ['HelloWorld'] |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
69 >>> os.listdir(os.path.join(directory, 'HelloWorld')) |
e4a97d6f2811
* add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
49
diff
changeset
|
70 ['HelloWorld-0.0.tar.gz'] |