annotate tests/test_ttw.txt @ 62:7c154953acc4

test reading the pages
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 01 Mar 2012 16:20:44 -0800
parents 53ec5144f84f
children 83327bc715be
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
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
8 >>> import urllib2
60
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 >>> from simpypi.factory import factory
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 Create a WSGI app::
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
46f5fd27ee54 stub testing TTW
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 >>> app = factory(directory=directory)
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
14
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
15 Now wrap it in a server::
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
16
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
17 >>> port = 64321
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
18 >>> server = testserver(app, 'localhost', port)
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
19 >>> server.start()
62
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
20 >>> url = 'http://localhost:%d/' % port
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
21
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
22 Get the home page::
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
23
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
24 >>> resource = urllib2.urlopen(url)
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
25 >>> contents = resource.read()
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
26 >>> 'Python Package Index' in contents
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
27 True
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
28
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
29 Get the index page::
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
30
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
31 >>> resource = urllib2.urlopen(url + 'index')
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
32 >>> contents = resource.read()
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
33 >>> 'Simple Index' in contents
7c154953acc4 test reading the pages
Jeff Hammel <jhammel@mozilla.com>
parents: 61
diff changeset
34 True
61
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
35
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
36 Shut down the server::
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
37
53ec5144f84f start serving PyPI
Jeff Hammel <jhammel@mozilla.com>
parents: 60
diff changeset
38 >>> server.stop()