Merge lp:~leonardr/launchpadlib/multiversion-fix into lp:launchpadlib

Proposed by Leonard Richardson
Status: Merged
Approved by: Muharem Hrnjadovic
Approved revision: 84
Merged at revision: not available
Proposed branch: lp:~leonardr/launchpadlib/multiversion-fix
Merge into: lp:launchpadlib
Diff against target: 94 lines (+36/-4)
4 files modified
src/launchpadlib/NEWS.txt (+12/-0)
src/launchpadlib/__init__.py (+1/-1)
src/launchpadlib/launchpad.py (+1/-1)
src/launchpadlib/tests/test_launchpad.py (+22/-2)
To merge this branch: bzr merge lp:~leonardr/launchpadlib/multiversion-fix
Reviewer Review Type Date Requested Status
Muharem Hrnjadovic (community) Approve
Review via email: mp+20585@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch fixes a very small bug in launchpadlib. There are two code paths in login_with() depending on whether the credentials were loaded from a file. The 'version' argument to login_with() was only being propagated in one of those code paths. So if your credentials were loaded from a file, you would always access the 'beta' version of the Launchpad web service, no matter what you'd requested.

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Looks good!

review: Approve

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 2009-12-17 17:32:12 +0000
3+++ src/launchpadlib/NEWS.txt 2010-03-03 18:45:23 +0000
4@@ -2,6 +2,18 @@
5 NEWS for launchpadlib
6 =====================
7
8+1.5.6 (2010-03-03)
9+==================
10+
11+- Fixed a minor bug when using login_with() to access a version of the
12+ Launchpad web service other than the default.
13+
14+1.5.5
15+=====
16+
17+- Added the ability to access different versions of the Launchpad web
18+ service.
19+
20 1.5.4 (2009-12-17)
21 ==================
22
23
24=== modified file 'src/launchpadlib/__init__.py'
25--- src/launchpadlib/__init__.py 2010-02-15 16:34:26 +0000
26+++ src/launchpadlib/__init__.py 2010-03-03 18:45:23 +0000
27@@ -14,4 +14,4 @@
28 # You should have received a copy of the GNU Lesser General Public License
29 # along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
30
31-__version__ = '1.5.5'
32+__version__ = '1.5.6'
33
34=== modified file 'src/launchpadlib/launchpad.py'
35--- src/launchpadlib/launchpad.py 2010-02-16 23:46:00 +0000
36+++ src/launchpadlib/launchpad.py 2010-03-03 18:45:23 +0000
37@@ -248,7 +248,7 @@
38 consumer_credentials_path)
39 launchpad = cls(
40 credentials, service_root=service_root, cache=cache_path,
41- timeout=timeout, proxy_info=proxy_info)
42+ timeout=timeout, proxy_info=proxy_info, version=version)
43 else:
44 launchpad = cls.get_token_and_login(
45 consumer_name, service_root=service_root, cache=cache_path,
46
47=== modified file 'src/launchpadlib/tests/test_launchpad.py'
48--- src/launchpadlib/tests/test_launchpad.py 2010-02-17 00:15:40 +0000
49+++ src/launchpadlib/tests/test_launchpad.py 2010-03-03 18:45:23 +0000
50@@ -148,6 +148,23 @@
51 mode = stat.S_IMODE(statinfo.st_mode)
52 self.assertEqual(mode, stat.S_IWRITE | stat.S_IREAD | stat.S_IEXEC)
53
54+ def test_version_is_propagated(self):
55+ # Make sure the login_with() method conveys the 'version' argument
56+ # all the way to the Launchpad object.
57+ launchpadlib_dir = os.path.join(self.temp_dir, 'launchpadlib')
58+ launchpad = NoNetworkLaunchpad.login_with(
59+ 'not important', service_root='http://api.example.com/',
60+ launchpadlib_dir=launchpadlib_dir, version="foo")
61+ self.assertEquals(launchpad.passed_in_kwargs['version'], 'foo')
62+
63+ # The second time we call login_with(), a different code path
64+ # is executed as the credentials are loaded from disk. Make
65+ # sure this code path propagates the 'version' argument as well.
66+ launchpad = NoNetworkLaunchpad.login_with(
67+ 'not important', service_root='http://api.example.com/',
68+ launchpadlib_dir=launchpadlib_dir, version="bar")
69+ self.assertEquals(launchpad.passed_in_kwargs['version'], 'bar')
70+
71 def test_no_credentials_calls_get_token_and_login(self):
72 # If no credentials are found, get_token_and_login() is called.
73 service_root = 'http://api.example.com/beta'
74@@ -250,16 +267,19 @@
75 access_token=AccessToken('access_key:84', 'access_secret:168'))
76 credentials.save_to_path(credentials_file_path)
77
78- service_root = 'http://api.example.com/beta'
79+ service_root = 'http://api.example.com/'
80 timeout = object()
81 proxy_info = object()
82+ version = "foo"
83 launchpad = NoNetworkLaunchpad.login_with(
84 'app name', launchpadlib_dir=self.temp_dir,
85- service_root=service_root, timeout=timeout, proxy_info=proxy_info)
86+ service_root=service_root, timeout=timeout, proxy_info=proxy_info,
87+ version=version)
88 expected_arguments = dict(
89 service_root=service_root,
90 timeout=timeout,
91 proxy_info=proxy_info,
92+ version=version,
93 cache=os.path.join(self.temp_dir, 'api.example.com', 'cache'))
94 self.assertEqual(launchpad.passed_in_kwargs, expected_arguments)
95

Subscribers

People subscribed via source and target branches