Merge lp:~leonardr/launchpadlib/fake-edge into lp:launchpadlib

Proposed by Leonard Richardson
Status: Merged
Approved by: Leonard Richardson
Approved revision: 117
Merged at revision: 114
Proposed branch: lp:~leonardr/launchpadlib/fake-edge
Merge into: lp:launchpadlib
Diff against target: 163 lines (+59/-11)
5 files modified
src/launchpadlib/NEWS.txt (+9/-2)
src/launchpadlib/__init__.py (+1/-1)
src/launchpadlib/launchpad.py (+3/-2)
src/launchpadlib/tests/test_launchpad.py (+37/-6)
src/launchpadlib/uris.py (+9/-0)
To merge this branch: bzr merge lp:~leonardr/launchpadlib/fake-edge
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+49651@code.launchpad.net

Description of the change

This branch reinstates the aliases for 'edge', but makes 'edge' equivalent to 'production'. Code like this will work again:

Launchpad.login_with("foo", "edge")
Launchpad.login_with("foo", EDGE_SERVICE_ROOT)

But it will give a DeprecationWarning.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

I think it would be an excellent idea to stick this branch into the version of launchpadlib found in Maverick.

Revision history for this message
Leonard Richardson (leonardr) wrote :

Here's a version of the branch that should be able to go into Maverick: https://code.launchpad.net/~leonardr/launchpadlib/edge-fakery-for-maverick

lp:~leonardr/launchpadlib/fake-edge updated
117. By Leonard Richardson

Split out the edge tests.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

The technical details went over my head at several points, but what I do understand looks good.

Thanks for splitting up the tests. They're much more specific this way. It'd be nice to have the "warning" tests separated from the "translation" tests as well, but that's getting into matters of taste perhaps.

Jeroen

review: Approve
Revision history for this message
Leonard Richardson (leonardr) wrote :

The standalone "translation" tests would just duplicate the "warning" tests and suppress the warning.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/launchpadlib/NEWS.txt'
2--- src/launchpadlib/NEWS.txt 2011-02-08 15:10:57 +0000
3+++ src/launchpadlib/NEWS.txt 2011-02-14 18:28:48 +0000
4@@ -2,14 +2,21 @@
5 NEWS for launchpadlib
6 =====================
7
8-1.9.5 (2010-02-08)
9+1.9.6 (2011-02-14)
10+==================
11+
12+- Added EDGE_SERVICE_ROOT and the 'edge' alias back, though they both
13+ operate on production behind the scenes. Using the 'edge' alias will
14+ cause a deprecation warning.
15+
16+1.9.5 (2011-02-08)
17 ==================
18
19 - Fixed a bug that prevented the deprecated get_token_and_login code
20 from working, and that required that users of get_token_and_login
21 get a new token on every usage.
22
23-1.9.4 (2010-01-18)
24+1.9.4 (2011-01-18)
25 ==================
26
27 - Removed references to the 'edge' service root, which is being phased out.
28
29=== modified file 'src/launchpadlib/__init__.py'
30--- src/launchpadlib/__init__.py 2011-02-07 19:54:03 +0000
31+++ src/launchpadlib/__init__.py 2011-02-14 18:28:48 +0000
32@@ -14,4 +14,4 @@
33 # You should have received a copy of the GNU Lesser General Public License
34 # along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
35
36-__version__ = '1.9.5'
37+__version__ = '1.9.6'
38
39=== modified file 'src/launchpadlib/launchpad.py'
40--- src/launchpadlib/launchpad.py 2011-02-07 20:08:28 +0000
41+++ src/launchpadlib/launchpad.py 2011-02-14 18:28:48 +0000
42@@ -45,10 +45,11 @@
43 from launchpadlib import uris
44
45
46-# Import some constants for backwards compatibility. This way, old
47+# Set some constants for backwards compatibility. This way, old
48 # scripts that have 'from launchpad import STAGING_SERVICE_ROOT' will still
49 # work.
50-from launchpadlib.uris import STAGING_SERVICE_ROOT
51+STAGING_SERVICE_ROOT = 'staging'
52+EDGE_SERVICE_ROOT = 'edge'
53 OAUTH_REALM = 'https://api.launchpad.net'
54
55
56
57=== modified file 'src/launchpadlib/tests/test_launchpad.py'
58--- src/launchpadlib/tests/test_launchpad.py 2011-01-18 21:57:09 +0000
59+++ src/launchpadlib/tests/test_launchpad.py 2011-02-14 18:28:48 +0000
60@@ -68,23 +68,54 @@
61
62 def setUp(self):
63 self.aliases = sorted(
64- ['production', 'qastaging', 'staging', 'dogfood', 'dev', 'test_dev'])
65+ ['production', 'qastaging', 'staging', 'dogfood', 'dev',
66+ 'test_dev', 'edge'])
67
68 def test_short_names(self):
69 # Ensure the short service names are all supported.
70 self.assertEqual(sorted(uris.service_roots.keys()), self.aliases)
71 self.assertEqual(sorted(uris.web_roots.keys()), self.aliases)
72
73+ def test_edge_service_root_is_production(self):
74+ # The edge server no longer exists, so if the client wants
75+ # edge we give them production.
76+ with warnings.catch_warnings(record=True) as caught:
77+ warnings.simplefilter("always")
78+ self.assertEqual(uris.lookup_service_root('edge'),
79+ uris.lookup_service_root('production'))
80+
81+ # The lookup caused a deprecation warning.
82+ self.assertEqual(len(caught), 1)
83+ warning, = caught
84+ self.assertTrue(issubclass(warning.category, DeprecationWarning))
85+ self.assertTrue("no longer exists" in warning.message.message)
86+
87+ def test_edge_service_root_is_production(self):
88+ # The edge server no longer exists, so if the client wants
89+ # edge we give them production.
90+ with warnings.catch_warnings(record=True) as caught:
91+ warnings.simplefilter("always")
92+ self.assertEqual(uris.lookup_web_root('edge'),
93+ uris.lookup_web_root('production'))
94+
95+ # The lookup caused a deprecation warning.
96+ self.assertEqual(len(caught), 1)
97+ warning, = caught
98+ self.assertTrue(issubclass(warning.category, DeprecationWarning))
99+ self.assertTrue("no longer exists" in warning.message.message)
100+
101 def test_lookups(self):
102 """Ensure that short service names turn into long service names."""
103
104 # If the service name is a known alias, lookup methods convert
105 # it to a URL.
106- for alias in self.aliases:
107- self.assertEqual(
108- uris.lookup_service_root(alias), uris.service_roots[alias])
109- self.assertEqual(
110- uris.lookup_web_root(alias), uris.web_roots[alias])
111+ with warnings.catch_warnings():
112+ warnings.simplefilter("ignore")
113+ for alias in self.aliases:
114+ self.assertEqual(
115+ uris.lookup_service_root(alias), uris.service_roots[alias])
116+ self.assertEqual(
117+ uris.lookup_web_root(alias), uris.web_roots[alias])
118
119 # If the service name is a valid URL, lookup methods let it
120 # through.
121
122=== modified file 'src/launchpadlib/uris.py'
123--- src/launchpadlib/uris.py 2011-01-18 21:57:09 +0000
124+++ src/launchpadlib/uris.py 2011-02-14 18:28:48 +0000
125@@ -28,9 +28,13 @@
126 ]
127
128 from urlparse import urlparse
129+import warnings
130 from lazr.uri import URI
131
132 LPNET_SERVICE_ROOT = 'https://api.launchpad.net/'
133+# Allow code that uses EDGE_SERVICE_ROOT to keep running,
134+# even though edge is gone.
135+EDGE_SERVICE_ROOT = LPNET_SERVICE_ROOT
136 QASTAGING_SERVICE_ROOT = 'https://api.qastaging.launchpad.net/'
137 STAGING_SERVICE_ROOT = 'https://api.staging.launchpad.net/'
138 DEV_SERVICE_ROOT = 'https://api.launchpad.dev/'
139@@ -47,6 +51,7 @@
140
141 service_roots = dict(
142 production=LPNET_SERVICE_ROOT,
143+ edge=LPNET_SERVICE_ROOT,
144 qastaging=QASTAGING_SERVICE_ROOT,
145 staging=STAGING_SERVICE_ROOT,
146 dogfood=DOGFOOD_SERVICE_ROOT,
147@@ -57,6 +62,7 @@
148
149 web_roots = dict(
150 production=LPNET_WEB_ROOT,
151+ edge = LPNET_WEB_ROOT,
152 qastaging=QASTAGING_WEB_ROOT,
153 staging=STAGING_WEB_ROOT,
154 dogfood=DOGFOOD_WEB_ROOT,
155@@ -67,6 +73,9 @@
156
157 def _dereference_alias(root, aliases):
158 """Dereference what might a URL or an alias for a URL."""
159+ if root == 'edge':
160+ warnings.warn(("Launchpad edge server no longer exists. "
161+ "Using 'production' instead."), DeprecationWarning)
162 if root in aliases:
163 return aliases[root]
164

Subscribers

People subscribed via source and target branches