Merge lp:~leonardr/launchpadlib/test-failures into lp:launchpadlib

Proposed by Leonard Richardson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~leonardr/launchpadlib/test-failures
Merge into: lp:launchpadlib
Diff against target: 107 lines (+34/-12)
2 files modified
src/launchpadlib/launchpad.py (+14/-10)
src/launchpadlib/tests/test_launchpad.py (+20/-2)
To merge this branch: bzr merge lp:~leonardr/launchpadlib/test-failures
Reviewer Review Type Date Requested Status
Gary Poster Approve
Review via email: mp+16303@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

This branch fixes some miscellaneous test failures I caused by running the launchpadlib doctests but not the unit tests. I also added a unit test that tests the anonymous login code, and changed login_anonymously so it would work with NoNetworkLaunchpad.

79. By Leonard Richardson

Fixed typo.

Revision history for this message
Gary Poster (gary) wrote :

merge-conditional

Looks good.

There's a formatting problem in line 39 of diff (should be two lines). Fix that and land it and I'll make the release!

Thank you

Gary

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/launchpadlib/launchpad.py'
--- src/launchpadlib/launchpad.py 2009-12-17 16:52:54 +0000
+++ src/launchpadlib/launchpad.py 2009-12-17 19:04:11 +0000
@@ -177,11 +177,12 @@
177 cls, consumer_name, service_root=uris.STAGING_SERVICE_ROOT,177 cls, consumer_name, service_root=uris.STAGING_SERVICE_ROOT,
178 launchpadlib_dir=None, timeout=None, proxy_info=None):178 launchpadlib_dir=None, timeout=None, proxy_info=None):
179 """Get access to Launchpad without providing any credentials."""179 """Get access to Launchpad without providing any credentials."""
180 service_root, service_root_dir, cache_path = cls._get_paths(180 (service_root, launchpadlib_dir, cache_path,
181 service_root, launchpadlib_dir)181 service_root_dir) = cls._get_paths(service_root, launchpadlib_dir)
182 token = AnonymousAccessToken()182 token = AnonymousAccessToken()
183 credentials = Credentials(consumer_name, access_token=token)183 credentials = Credentials(consumer_name, access_token=token)
184 return cls(credentials, service_root, cache_path, timeout, proxy_info)184 return cls(credentials, service_root=service_root, cache=cache_path,
185 timeout=timeout, proxy_info=proxy_info)
185186
186 @classmethod187 @classmethod
187 def login_with(cls, consumer_name,188 def login_with(cls, consumer_name,
@@ -224,8 +225,8 @@
224 :rtype: `Launchpad`225 :rtype: `Launchpad`
225226
226 """227 """
227 service_root, service_root_dir, cache_path = cls._get_paths(228 (service_root, launchpadlib_dir, cache_path,
228 service_root, launchpadlib_dir)229 service_root_dir) = cls._get_paths(service_root, launchpadlib_dir)
229 credentials_path = os.path.join(service_root_dir, 'credentials')230 credentials_path = os.path.join(service_root_dir, 'credentials')
230 if not os.path.exists(credentials_path):231 if not os.path.exists(credentials_path):
231 os.makedirs(credentials_path)232 os.makedirs(credentials_path)
@@ -261,10 +262,13 @@
261 :param service_root: The service root the user wants to262 :param service_root: The service root the user wants to
262 connect to. This may be an alias (which will be263 connect to. This may be an alias (which will be
263 dereferenced to a URL and returned) or a URL (which will264 dereferenced to a URL and returned) or a URL (which will
264 be returned as is).265 be returned as is). :param launchpadlib_dir: The user's
265 :param launchpadlib_dir: The user's base launchpadlib directory,266 base launchpadlib directory, if known. This may be
266 if known.267 modified, expanded, or determined from the environment if
267 :return: A 3-tuple: (service_root_uri, cache_dir, service_root_dir)268 missing. A definitive value will be returned.
269
270 :return: A 4-tuple:
271 (service_root_uri, launchpadlib_dir, cache_dir, service_root_dir)
268 """272 """
269 if launchpadlib_dir is None:273 if launchpadlib_dir is None:
270 home_dir = os.environ['HOME']274 home_dir = os.environ['HOME']
@@ -282,4 +286,4 @@
282 cache_path = os.path.join(service_root_dir, 'cache')286 cache_path = os.path.join(service_root_dir, 'cache')
283 if not os.path.exists(cache_path):287 if not os.path.exists(cache_path):
284 os.makedirs(cache_path)288 os.makedirs(cache_path)
285 return (service_root, cache_path, service_root_dir)289 return (service_root, launchpadlib_dir, cache_path, service_root_dir)
286290
=== modified file 'src/launchpadlib/tests/test_launchpad.py'
--- src/launchpadlib/tests/test_launchpad.py 2009-12-03 15:46:27 +0000
+++ src/launchpadlib/tests/test_launchpad.py 2009-12-17 19:04:11 +0000
@@ -24,7 +24,8 @@
24import tempfile24import tempfile
25import unittest25import unittest
2626
27from launchpadlib.credentials import AccessToken, Credentials27from launchpadlib.credentials import (
28 AccessToken, AuthorizeRequestTokenWithBrowser, Credentials)
28from launchpadlib.launchpad import Launchpad29from launchpadlib.launchpad import Launchpad
29from launchpadlib import uris30from launchpadlib import uris
3031
@@ -62,7 +63,7 @@
6263
63 def setUp(self):64 def setUp(self):
64 self.aliases = sorted(65 self.aliases = sorted(
65 ['production', 'edge', 'staging', 'dogfood', 'dev'])66 ['production', 'edge', 'staging', 'dogfood', 'dev', 'test_dev'])
6667
67 def test_short_names(self):68 def test_short_names(self):
68 # Ensure the short service names are all supported.69 # Ensure the short service names are all supported.
@@ -157,12 +158,29 @@
157 service_root=service_root, timeout=timeout, proxy_info=proxy_info)158 service_root=service_root, timeout=timeout, proxy_info=proxy_info)
158 self.assertEqual(launchpad.consumer_name, 'app name')159 self.assertEqual(launchpad.consumer_name, 'app name')
159 expected_arguments = dict(160 expected_arguments = dict(
161 allow_access_levels=[],
162 authorizer_class=AuthorizeRequestTokenWithBrowser,
163 max_failed_attempts=3,
160 service_root=service_root,164 service_root=service_root,
161 timeout=timeout,165 timeout=timeout,
162 proxy_info=proxy_info,166 proxy_info=proxy_info,
163 cache=os.path.join(self.temp_dir, 'api.example.com', 'cache'))167 cache=os.path.join(self.temp_dir, 'api.example.com', 'cache'))
164 self.assertEqual(launchpad.passed_in_kwargs, expected_arguments)168 self.assertEqual(launchpad.passed_in_kwargs, expected_arguments)
165169
170 def test_anonymous_login(self):
171 """Test the anonymous login helper function."""
172 launchpad = NoNetworkLaunchpad.login_anonymously(
173 'anonymous access', launchpadlib_dir=self.temp_dir,
174 service_root='http://api.example.com/beta')
175 self.assertEqual(launchpad.credentials.access_token.key, '')
176 self.assertEqual(launchpad.credentials.access_token.secret, '')
177
178 # Test that anonymous credentials are not saved.
179 credentials_path = os.path.join(
180 self.temp_dir, 'api.example.com', 'credentials',
181 'anonymous access')
182 self.assertFalse(os.path.exists(credentials_path))
183
166 def test_new_credentials_are_saved(self):184 def test_new_credentials_are_saved(self):
167 # After get_token_and_login() have been called, the created185 # After get_token_and_login() have been called, the created
168 # credentials are saved.186 # credentials are saved.

Subscribers

People subscribed via source and target branches