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