annotate tests/doctest.txt @ 50:e4a97d6f2811

* add kinda a redundant test * stub out introspecting packages
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 01 Mar 2012 14:26:28 -0800
parents ca456e08924f
children 6a8071eab89e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
5ee4fe3decd9 more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
1 Test simpypi
5ee4fe3decd9 more stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
2 ============
6
232e67cac00c stub testing
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
232e67cac00c stub testing
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 The obligatory imports::
232e67cac00c stub testing
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
33
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
6 >>> import os
44
d9bc2a586ed4 add an import
Jeff Hammel <jhammel@mozilla.com>
parents: 43
diff changeset
7 >>> import shutil
6
232e67cac00c stub testing
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 >>> import simpypi
50
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
9 >>> import tempfile
33
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
10 >>> from paste.fixture import TestApp
6
232e67cac00c stub testing
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
33
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
12 The directory is initially empty::
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
13
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
14 >>> os.listdir(directory)
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
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
17 Make a test application::
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 >>> app = simpypi.SimPyPI(directory)
058182b7b309 note test-requires.txt in the readme
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
20 >>> testapp = TestApp(app)
36
a02d08627d9c stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
21
a02d08627d9c stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
22 Upload a package::
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 >>> field = 'package'
a02d08627d9c stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
25 >>> filename = 'HelloWorld-0.0.tar.gz'
a02d08627d9c stub a test to upload a package
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
26 >>> contents = file(os.path.join(here, filename)).read()
37
1bdece293671 * fix calling signature in test
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
27 >>> 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
28
089d5650d7e2 check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
29 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
30
089d5650d7e2 check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
31 >>> os.listdir(directory)
089d5650d7e2 check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
32 ['HelloWorld']
089d5650d7e2 check for the package in the right place
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
33 >>> 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
34 ['HelloWorld-0.0.tar.gz']
47
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
35
50
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
36 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
37
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
38 >>> tmpdir = tempfile.mkdtemp()
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
39 >>> shutil.rmtree(tmpdir)
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
40
47
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
41 Upload the same package but with the wrong name::
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
42
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
43 >>> shutil.rmtree(os.path.join(directory, 'HelloWorld'))
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
44 >>> os.listdir(directory)
cb24b5265557 clean out tmpdir
Jeff Hammel <jhammel@mozilla.com>
parents: 44
diff changeset
45 []
49
ca456e08924f add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents: 47
diff changeset
46 >>> 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
47 >>> os.listdir(directory)
ca456e08924f add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents: 47
diff changeset
48 ['HelloWorld']
ca456e08924f add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents: 47
diff changeset
49 >>> os.listdir(os.path.join(directory, 'HelloWorld'))
ca456e08924f add a test for misnamed files
Jeff Hammel <jhammel@mozilla.com>
parents: 47
diff changeset
50 ['HelloWorld-0.0.tar.gz']
50
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
51 >>> shutil.rmtree(os.path.join(directory, 'HelloWorld'))
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
52 >>> os.listdir(directory)
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
53 []
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
54 >>> filename = 'MisleadingFilename.tar.gz'
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
55 >>> contents = file(os.path.join(here, filename)).read()
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
56 >>> response = testapp.post('/', upload_files=[(field, filename, contents)])
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
57 >>> os.listdir(directory)
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
58 ['HelloWorld']
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
59 >>> os.listdir(os.path.join(directory, 'HelloWorld'))
e4a97d6f2811 * add kinda a redundant test
Jeff Hammel <jhammel@mozilla.com>
parents: 49
diff changeset
60 ['HelloWorld-0.0.tar.gz']