Merge lp:~leonardr/launchpadlib/edge-replacement-for-maverick into lp:launchpadlib

Proposed by Leonard Richardson
Status: Work in progress
Proposed branch: lp:~leonardr/launchpadlib/edge-replacement-for-maverick
Merge into: lp:launchpadlib
Diff against target: 154 lines (+62/-3) (has conflicts)
2 files modified
src/launchpadlib/tests/test_launchpad.py (+27/-0)
src/launchpadlib/uris.py (+35/-3)
Text conflict in src/launchpadlib/tests/test_launchpad.py
Text conflict in src/launchpadlib/uris.py
To merge this branch: bzr merge lp:~leonardr/launchpadlib/edge-replacement-for-maverick
Reviewer Review Type Date Requested Status
Barry Warsaw Pending
Review via email: mp+49808@code.launchpad.net

Description of the change

This branch makes three small changes to launchpadlib that would be useful to backport to launchpadlib version 1.6.1, the version currently in Maverick.

1. It fixes a tiny test failure where the code expects launchpadlib to be using the 'beta' web service, even though the default is now '1.0'.
2. It introduces an alias for the qastaging Launchpad instance, so you can do Launchpad.login_with("my-app", "qastaging").
3. The "edge" Launchpad instance is deprecated. This branch introduces code that intercepts any attempt to access this instance, prints a deprecation warning, and uses the "production" instance instead.

The code is here: https://pastebin.canonical.com/43343/

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

(Sorry for using the Canonical pastebin, but the Ubuntu one is down right now.)

Revision history for this message
Robert Collins (lifeless) wrote :

This would be good to land, but it has conflicts. I'm going to put it back into WIP for now.

Unmerged revisions

90. By Leonard Richardson

Backported the deprecation of edge and the creation of qastaging. Also fixed a random failing test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/launchpadlib/tests/test_launchpad.py'
2--- src/launchpadlib/tests/test_launchpad.py 2011-02-15 13:11:51 +0000
3+++ src/launchpadlib/tests/test_launchpad.py 2011-02-15 14:03:00 +0000
4@@ -25,9 +25,13 @@
5 import stat
6 import tempfile
7 import unittest
8+<<<<<<< TREE
9 import warnings
10
11 from lazr.restfulclient.resource import ServiceRoot
12+=======
13+import warnings
14+>>>>>>> MERGE-SOURCE
15
16 from launchpadlib.credentials import (
17 AccessToken,
18@@ -69,6 +73,7 @@
19
20 def setUp(self):
21 self.aliases = sorted(
22+<<<<<<< TREE
23 ['production', 'qastaging', 'staging', 'dogfood', 'dev',
24 'test_dev', 'edge'])
25
26@@ -84,6 +89,23 @@
27 warning, = caught
28 self.assertTrue(issubclass(warning.category, DeprecationWarning))
29 self.assertTrue("no longer exists" in warning.message.message)
30+=======
31+ ['production', 'edge', 'staging', 'qastaging', 'dogfood', 'dev',
32+ 'test_dev'])
33+
34+ @contextmanager
35+ def edge_deprecation_error(self):
36+ # Run some code and assert that a deprecation error was issued
37+ # due to attempted access to the edge server.
38+ with warnings.catch_warnings(record=True) as caught:
39+ warnings.simplefilter("always")
40+ yield
41+
42+ self.assertEqual(len(caught), 1)
43+ warning, = caught
44+ self.assertTrue(issubclass(warning.category, DeprecationWarning))
45+ self.assertTrue("no longer exists" in warning.message.message)
46+>>>>>>> MERGE-SOURCE
47
48 def test_short_names(self):
49 # Ensure the short service names are all supported.
50@@ -479,10 +501,15 @@
51 expected_arguments = dict(
52 service_root=SERVICE_ROOT,
53 cache=os.path.join(self.temp_dir, 'api.example.com', 'cache'),
54+<<<<<<< TREE
55 timeout=timeout,
56 proxy_info=proxy_info,
57 version=NoNetworkLaunchpad.DEFAULT_VERSION)
58 self.assertEqual(launchpad.passed_in_args, expected_arguments)
59+=======
60+ version='1.0')
61+ self.assertEqual(launchpad.passed_in_kwargs, expected_arguments)
62+>>>>>>> MERGE-SOURCE
63
64 def test_anonymous_login(self):
65 """Test the anonymous login helper function."""
66
67=== modified file 'src/launchpadlib/uris.py'
68--- src/launchpadlib/uris.py 2011-02-15 12:03:58 +0000
69+++ src/launchpadlib/uris.py 2011-02-15 14:03:00 +0000
70@@ -28,12 +28,20 @@
71 ]
72
73 from urlparse import urlparse
74+<<<<<<< TREE
75 import warnings
76 from lazr.uri import URI
77+=======
78+import warnings
79+>>>>>>> MERGE-SOURCE
80
81 LPNET_SERVICE_ROOT = 'https://api.launchpad.net/'
82+<<<<<<< TREE
83 QASTAGING_SERVICE_ROOT = 'https://api.qastaging.launchpad.net/'
84+=======
85+>>>>>>> MERGE-SOURCE
86 STAGING_SERVICE_ROOT = 'https://api.staging.launchpad.net/'
87+QASTAGING_SERVICE_ROOT = 'https://api.qastaging.launchpad.net/'
88 DEV_SERVICE_ROOT = 'https://api.launchpad.dev/'
89 DOGFOOD_SERVICE_ROOT = 'https://api.dogfood.launchpad.net/'
90 TEST_DEV_SERVICE_ROOT = 'http://api.launchpad.dev:8085/'
91@@ -64,8 +72,13 @@
92
93 web_roots = dict(
94 production=LPNET_WEB_ROOT,
95+<<<<<<< TREE
96 edge = LPNET_WEB_ROOT,
97 qastaging=QASTAGING_WEB_ROOT,
98+=======
99+ edge=LPNET_WEB_ROOT,
100+ qastaging=QASTAGING_WEB_ROOT,
101+>>>>>>> MERGE-SOURCE
102 staging=STAGING_WEB_ROOT,
103 dogfood=DOGFOOD_WEB_ROOT,
104 dev=DEV_WEB_ROOT,
105@@ -75,9 +88,16 @@
106
107 def _dereference_alias(root, aliases):
108 """Dereference what might a URL or an alias for a URL."""
109- if root == 'edge':
110- warnings.warn(("Launchpad edge server no longer exists. "
111- "Using 'production' instead."), DeprecationWarning)
112+<<<<<<< TREE
113+ if root == 'edge':
114+ warnings.warn(("Launchpad edge server no longer exists. "
115+ "Using 'production' instead."), DeprecationWarning)
116+=======
117+ if root == 'edge':
118+ warnings.warn(("Launchpad edge server no longer exists. "
119+ "Using 'production' instead."), DeprecationWarning)
120+
121+>>>>>>> MERGE-SOURCE
122 if root in aliases:
123 return aliases[root]
124
125@@ -98,9 +118,15 @@
126 appropriate URI. A URI gets returned as is. Any other string raises a
127 ValueError.
128 """
129+<<<<<<< TREE
130 if service_root == EDGE_SERVICE_ROOT:
131 # This will trigger a deprecation warning and use production instead.
132 service_root = 'edge'
133+=======
134+ if service_root == EDGE_SERVICE_ROOT:
135+ # This will trigger a deprecation warning.
136+ service_root = 'edge'
137+>>>>>>> MERGE-SOURCE
138 return _dereference_alias(service_root, service_roots)
139
140
141@@ -111,9 +137,15 @@
142 appropriate URI. A URI gets returned as is. Any other string raises a
143 ValueError.
144 """
145+<<<<<<< TREE
146 if web_root == EDGE_WEB_ROOT:
147 # This will trigger a deprecation warning and use production instead.
148 web_root = 'edge'
149+=======
150+ if web_root == EDGE_WEB_ROOT:
151+ # This will trigger a deprecation warning.
152+ web_root = 'edge'
153+>>>>>>> MERGE-SOURCE
154 return _dereference_alias(web_root, web_roots)
155
156

Subscribers

People subscribed via source and target branches