annotate tests/test_ttw.txt @ 65:83327bc715be

make the virtualenv convenience method return more stuff
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 01 Mar 2012 18:31:52 -0800
parents 7c154953acc4
children a2ba66be2e31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 Test Through The Web
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 ====================
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 Test ``simpypi`` through the web with a test server.
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 The obligatory imports::
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
65
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
8 >>> import os
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
9 >>> import urllib2
60
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 >>> from simpypi.factory import factory
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 Create a WSGI app::
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 >>> app = factory(directory=directory)
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
15
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
16 Now wrap it in a server::
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
17
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
18 >>> port = 64321
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
19 >>> server = testserver(app, 'localhost', port)
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
20 >>> server.start()
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
21 >>> url = 'http://localhost:%d/' % port
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
22
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
23 Get the home page::
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
24
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
25 >>> resource = urllib2.urlopen(url)
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
26 >>> contents = resource.read()
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
27 >>> 'Python Package Index' in contents
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
28 True
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
29
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
30 Get the index page::
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
31
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
32 >>> resource = urllib2.urlopen(url + 'index')
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
33 >>> contents = resource.read()
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
34 >>> 'Simple Index' in contents
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
35 True
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
36
65
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
37
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
38 There should be no files to start out with::
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
39
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
40 >>> os.listdir(directory)
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
41 []
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
42
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
43 Upload a file::
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
44
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
45 >>> path = os.path.join(here, 'HelloWorld-0.0.tar.gz')
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
46 >>> upload = MultiPartForm()
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
47 >>> upload.add_file('package', path)
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
48 >>> response = upload.post(url)
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
49
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
50 Let's see if its in the right place::
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
51
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
52 >>> os.listdir(directory)
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
53 ['HelloWorld']
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
54 >>> os.listdir(os.path.join(directory, 'HelloWorld'))
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
55 ['HelloWorld-0.0.tar.gz']
83327bc715be make the virtualenv convenience method return more stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 62
diff changeset
56
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
57 Shut down the server::
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
58
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
59 >>> server.stop()