Merge lp:~salgado/launchpad/revert-10575-and-fix-tests into lp:launchpad

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/revert-10575-and-fix-tests
Merge into: lp:launchpad
Diff against target: 332 lines (+84/-105)
9 files modified
Makefile (+4/-0)
lib/canonical/launchpad/apidoc/wadl-testrunner-devel.xml (+10/-0)
lib/canonical/launchpad/pagetests/standalone/xx-form-layout.txt (+6/-4)
lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt (+0/-11)
lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt (+59/-68)
lib/canonical/launchpad/systemhomes.py (+4/-9)
lib/canonical/launchpad/testing/pages.py (+0/-5)
lib/canonical/testing/layers.py (+0/-7)
lib/lp/registry/stories/product/xx-product-add.txt (+1/-1)
To merge this branch: bzr merge lp:~salgado/launchpad/revert-10575-and-fix-tests
Reviewer Review Type Date Requested Status
Canonical Launchpad Engineering Pending
Review via email: mp+22219@code.launchpad.net

Description of the change

Reverts 10575 and fixes the two page tests that are known to be failing

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2010-03-25 02:21:15 +0000
3+++ Makefile 2010-03-26 13:37:35 +0000
4@@ -324,7 +324,11 @@
5 $(RM) -r lib/mailman
6 $(RM) -rf lib/canonical/launchpad/icing/build/*
7 $(RM) -r $(CODEHOSTING_ROOT)
8+ mv $(APIDOC_DIR)/wadl-testrunner-devel.xml \
9+ $(APIDOC_DIR)/wadl-testrunner-devel.xml.bak
10 $(RM) $(APIDOC_DIR)/wadl*.xml $(APIDOC_DIR)/*.html
11+ mv $(APIDOC_DIR)/wadl-testrunner-devel.xml.bak \
12+ $(APIDOC_DIR)/wadl-testrunner-devel.xml
13 $(RM) -rf $(APIDOC_DIR).tmp
14 $(RM) $(BZR_VERSION_INFO)
15 $(RM) _pythonpath.py
16
17=== added file 'lib/canonical/launchpad/apidoc/wadl-testrunner-devel.xml'
18--- lib/canonical/launchpad/apidoc/wadl-testrunner-devel.xml 1970-01-01 00:00:00 +0000
19+++ lib/canonical/launchpad/apidoc/wadl-testrunner-devel.xml 2010-03-26 13:37:35 +0000
20@@ -0,0 +1,10 @@
21+<?xml version="1.0"?>
22+<wadl:application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+ xmlns="http://research.sun.com/wadl/2006/10"
24+ xmlns:wadl="http://research.sun.com/wadl/2006/10"
25+ xsi:schemaLocation="http://research.sun.com/wadl/2006/10/wadl.xsd">
26+
27+ <!--This file is for testing purposes only. See
28+ canonical/launcpad/pagetests/webservice/xx-wadl.txt -->
29+
30+</wadl:application>
31
32=== modified file 'lib/canonical/launchpad/pagetests/standalone/xx-form-layout.txt'
33--- lib/canonical/launchpad/pagetests/standalone/xx-form-layout.txt 2009-07-29 14:18:29 +0000
34+++ lib/canonical/launchpad/pagetests/standalone/xx-form-layout.txt 2010-03-26 13:37:35 +0000
35@@ -60,8 +60,9 @@
36 <label for="field.teamdescription">Team Description:</label>
37 <span ...
38 <div><textarea ... name="field.teamdescription" ...></textarea></div>
39- <p class="formHelp">Include information on how to get involved with
40- development. Use plain text; URLs will be linkified.</p>
41+ <p class="formHelp">Details about the team's work, highlights, goals,
42+ and how to contribute. Use plain text, paragraphs are preserved and
43+ URLs are linked in pages.</p>
44 </td>
45 </tr>
46 ...
47@@ -76,8 +77,9 @@
48 <label for="field.teamdescription">Team Description:</label>
49 <span class="fieldRequired">(Optional)</span>
50 <div><textarea ... name="field.teamdescription" ...></textarea></div>
51- <p class="formHelp">Include information on how to get involved with
52- development. Use plain text; URLs will be linkified.</p>
53+ <p class="formHelp">Details about the team's work, highlights, goals,
54+ and how to contribute. Use plain text, paragraphs are preserved and
55+ URLs are linked in pages.</p>
56 </td>
57 </tr>
58 ...
59
60=== removed file 'lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt'
61--- lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 2010-03-23 13:36:27 +0000
62+++ lib/canonical/launchpad/pagetests/webservice/launchpadlib.txt 1970-01-01 00:00:00 +0000
63@@ -1,11 +0,0 @@
64-Using launchpadlib in pagetests
65-===============================
66-
67-As an alternative to crafting HTTP requests with the 'webservice'
68-object, you can write pagetests using launchpadlib. The 'launchpad'
69-variable contains a launchpadlib Launchpad object that's
70-pre-authenticated with salgado's permissions. Anything you can do with
71-'webservice', you can do with 'launchpad'.
72-
73- >>> print launchpad.me.name
74- salgado
75
76=== modified file 'lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt'
77--- lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt 2010-03-23 14:48:10 +0000
78+++ lib/canonical/launchpad/pagetests/webservice/xx-wadl.txt 2010-03-26 13:37:35 +0000
79@@ -3,83 +3,55 @@
80 Because Launchpad's main WADL files are so big, we cache them
81 internally: one WADL file for every version of the web service.
82 Because the WADL only changes when the Launchpad software changes,
83-these documents are cached to files.
84-
85-This test shows how the cache works. We'll start by temporarily
86-clearing the cache.
87+these documents are cached to files. Right now, the Launchpad
88+webservice serves a special test file
89+(canonical/launchpad/apidoc/wadl-testrunner-devel.xml) when a client
90+asks for the big WADL definition for the 'devel' version. The
91+'testrunner' part comes from canonical.config.config.instance_name, so
92+a development instance will use the file
93+canonical/launchpad/apidoc/wadl-development-{version}.xml.
94+
95+ >>> test_wadl = webservice.get(
96+ ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
97+ >>> print test_wadl
98+ <?xml version="1.0"?>
99+ <wadl:application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
100+ xmlns="http://research.sun.com/wadl/2006/10"
101+ xmlns:wadl="http://research.sun.com/wadl/2006/10"
102+ xsi:schemaLocation="http://research.sun.com/wadl/2006/10/wadl.xsd">
103+ <BLANKLINE>
104+ <!--This file is for testing purposes only. See
105+ canonical/launcpad/pagetests/webservice/xx-wadl.txt -->
106+ <BLANKLINE>
107+ </wadl:application>
108+ <BLANKLINE>
109+
110+Let's look at the real contents, though. To do this, we need to
111+deactivate the cache. Simply clearing it out will just cause it to be
112+filled up again.
113
114 >>> from canonical.launchpad.systemhomes import WebServiceApplication
115 >>> old_cached_wadl = WebServiceApplication.cached_wadl
116- >>> WebServiceApplication.cached_wadl = {}
117-
118-If WADL is present in a certain file on disk--the filename depends on
119-the Launchpad configuration and the web service version--it will be
120-loaded from disk and not generated from scratch. But the testrunner
121-does not have any WADL files written to disk.
122-
123- >>> import os
124- >>> wadl_filename = WebServiceApplication.cachedWADLPath(
125- ... 'testrunner', 'devel')
126- >>> os.path.exists(wadl_filename)
127- False
128-
129-Let's write some fake WADL to disk.
130-
131- >>> fd = open(wadl_filename, "w")
132- >>> fd.write("Some fake WADL.")
133- >>> fd.close()
134-
135-When we request the WADL for version "devel", the fake WADL is loaded
136-from disk.
137-
138- >>> print webservice.get(
139- ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
140- Some fake WADL.
141-
142-The fake WADL is now present in the cache.
143-
144- >>> WebServiceApplication.cached_wadl
145- {u'devel': u'Some fake WADL.'}
146-
147-Change the cached value, and we change the document served.
148-
149- >>> WebServiceApplication.cached_wadl['devel'] = "More fake WADL."
150-
151- >>> print webservice.get(
152- ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
153- More fake WADL.
154-
155-If there's no value in the cache and no cached file on disk, the WADL
156-is generated from scratch.
157-
158- >>> WebServiceApplication.cached_wadl = {}
159- >>> os.remove(wadl_filename)
160+ >>> WebServiceApplication.cached_wadl = None
161
162 >>> wadl = webservice.get(
163 ... '/', 'application/vd.sun.wadl+xml', api_version='devel').body
164 >>> wadl = wadl.decode('UTF-8')
165
166-Unlike the test strings we used earlier, this is a valid WADL file.
167-
168- >>> from lazr.restful import WADL_SCHEMA_FILE
169- >>> from canonical.lazr.xml import XMLValidator
170- >>> wadl_schema = XMLValidator(WADL_SCHEMA_FILE)
171-
172- # We need to replace the nbsp entity, because the validator
173- # doesn't support embedded definition.
174- >>> wadl_schema.validate(
175- ... wadl.replace('&nbsp;', '&#160;').encode('UTF-8'))
176+The real file is much bigger than the test file.
177+
178+ >>> len(wadl) > len(test_wadl)
179 True
180
181 The WADL we received is keyed to the 'devel' version of the web
182-service. The URL to this version's service root will always be
183-present.
184+service. This version will always be present.
185
186 >>> 'http://api.launchpad.dev/devel/' in wadl
187 True
188
189 If we retrieve the WADL for the '1.0' version of the web service,
190-we'll get a document keyed to the '1.0' version.
191+we'll get a document keyed to the '1.0' version. The '1.0' version
192+will be deprecated along with the Lucid release of Ubuntu.
193
194 >>> wadl_10 = webservice.get(
195 ... '/', 'application/vd.sun.wadl+xml', api_version='1.0').body
196@@ -88,12 +60,31 @@
197 >>> 'http://api.launchpad.dev/1.0/' in wadl_10
198 True
199
200-All of these documents were cached as they were generated:
201-
202- >>> sorted(WebServiceApplication.cached_wadl.keys())
203- [u'1.0', u'devel']
204-
205-Finally, restore the cache so that other tests will have a clean
206-slate.
207+If we retrieve the WADL for the 'beta' version of the web service,
208+we'll get a document keyed to the 'beta' version. The '1.0' version
209+will be deprecated along with the Karmic release of Ubuntu.
210+
211+ >>> wadl_beta = webservice.get(
212+ ... '/', 'application/vd.sun.wadl+xml', api_version='beta').body
213+ >>> wadl_beta = wadl_beta.decode('UTF-8')
214+
215+ >>> 'http://api.launchpad.dev/beta/' in wadl_beta
216+ True
217+
218+We don't need the cache anymore, so we'll reinstate the testing
219+version. This way, other tests will have a clean slate.
220
221 >>> WebServiceApplication.cached_wadl = old_cached_wadl
222+
223+Like all lazr.restful applications, Launchpad's web service generates
224+valid WADL.
225+
226+ >>> from lazr.restful import WADL_SCHEMA_FILE
227+ >>> from canonical.lazr.xml import XMLValidator
228+ >>> wadl_schema = XMLValidator(WADL_SCHEMA_FILE)
229+
230+ # We need to replace the nbsp entity, because the validator
231+ # doesn't support embedded definition.
232+ >>> wadl_schema.validate(
233+ ... wadl.replace('&nbsp;', '&#160;').encode('UTF-8'))
234+ True
235
236=== modified file 'lib/canonical/launchpad/systemhomes.py'
237--- lib/canonical/launchpad/systemhomes.py 2010-03-23 11:43:06 +0000
238+++ lib/canonical/launchpad/systemhomes.py 2010-03-26 13:37:35 +0000
239@@ -354,13 +354,6 @@
240
241 cached_wadl = {}
242
243- @classmethod
244- def cachedWADLPath(cls, instance_name, version):
245- """Helper method to calculate the path to a cached WADL file."""
246- return os.path.join(
247- os.path.dirname(os.path.normpath(__file__)),
248- 'apidoc', 'wadl-%s-%s.xml' % (instance_name, version))
249-
250 def toWADL(self):
251 """See `IWebServiceApplication`.
252
253@@ -377,8 +370,10 @@
254 return super(WebServiceApplication, self).toWADL()
255 if version not in self.__class__.cached_wadl:
256 # It's not cached. Look for it on disk.
257- _wadl_filename = self.cachedWADLPath(
258- config.instance_name, version)
259+ _wadl_filename = os.path.join(
260+ os.path.dirname(os.path.normpath(__file__)),
261+ 'apidoc', 'wadl-%s-%s.xml' % (config.instance_name, version))
262+
263 _wadl_fd = None
264 try:
265 _wadl_fd = codecs.open(_wadl_filename, encoding='UTF-8')
266
267=== modified file 'lib/canonical/launchpad/testing/pages.py'
268--- lib/canonical/launchpad/testing/pages.py 2010-03-23 13:36:27 +0000
269+++ lib/canonical/launchpad/testing/pages.py 2010-03-26 13:37:35 +0000
270@@ -29,8 +29,6 @@
271 from zope.testing import doctest
272 from zope.security.proxy import removeSecurityProxy
273
274-from launchpadlib.launchpad import Launchpad
275-
276 from canonical.launchpad.interfaces import (
277 IOAuthConsumerSet, OAUTH_REALM, ILaunchpadCelebrities,
278 TeamMembershipStatus)
279@@ -727,9 +725,6 @@
280 'launchpad-library', 'nopriv-read-nonprivate')
281 test.globs['anon_webservice'] = LaunchpadWebServiceCaller(
282 'launchpad-library', '')
283- test.globs['launchpad'] = Launchpad.login(
284- 'launchpad-library', 'salgado-change-anything', 'test',
285- service_root='http://api.launchpad.dev/', version="devel")
286 test.globs['setupBrowser'] = setupBrowser
287 test.globs['setupDTCBrowser'] = setupDTCBrowser
288 test.globs['setupRosettaExpertBrowser'] = setupRosettaExpertBrowser
289
290=== modified file 'lib/canonical/testing/layers.py'
291--- lib/canonical/testing/layers.py 2010-03-23 13:51:03 +0000
292+++ lib/canonical/testing/layers.py 2010-03-26 13:37:35 +0000
293@@ -73,7 +73,6 @@
294 from storm.zope.interfaces import IZStorm
295 import transaction
296 import wsgi_intercept
297-from wsgi_intercept import httplib2_intercept
298
299 from lazr.restful.utils import safe_hasattr
300
301@@ -939,18 +938,12 @@
302 register_launchpad_request_publication_factories()
303 wsgi_intercept.add_wsgi_intercept(
304 'localhost', 80, lambda: wsgi_application)
305- wsgi_intercept.add_wsgi_intercept(
306- 'api.launchpad.dev', 80, lambda: wsgi_application)
307- httplib2_intercept.install()
308-
309
310 @classmethod
311 @profiled
312 def tearDown(cls):
313 FunctionalLayer.isSetUp = False
314 wsgi_intercept.remove_wsgi_intercept('localhost', 80)
315- wsgi_intercept.remove_wsgi_intercept('api.launchpad.dev', 80)
316- httplib2_intercept.uninstall()
317 # Signal Layer cannot be torn down fully
318 raise NotImplementedError
319
320
321=== modified file 'lib/lp/registry/stories/product/xx-product-add.txt'
322--- lib/lp/registry/stories/product/xx-product-add.txt 2010-01-08 16:37:33 +0000
323+++ lib/lp/registry/stories/product/xx-product-add.txt 2010-03-26 13:37:35 +0000
324@@ -51,7 +51,7 @@
325 The project title. Should be just a few words.
326 Summary:
327 Required input is missing.
328- The summary should be a single short paragraph.
329+ A short paragraph to introduce the project's work.
330
331 Realizing her mistake, Sample Person fills out the project's basic information
332 correctly this time.