Merge lp:~leonardr/launchpadlib/find-length into lp:launchpadlib

Proposed by Leonard Richardson
Status: Merged
Approved by: Aaron Bentley
Approved revision: 96
Merged at revision: 96
Proposed branch: lp:~leonardr/launchpadlib/find-length
Merge into: lp:launchpadlib
Diff against target: 112 lines (+47/-3)
5 files modified
src/launchpadlib/NEWS.txt (+5/-0)
src/launchpadlib/__init__.py (+1/-1)
src/launchpadlib/docs/operations.txt (+27/-0)
src/launchpadlib/launchpad.py (+2/-2)
src/launchpadlib/tests/test_launchpad.py (+12/-0)
To merge this branch: bzr merge lp:~leonardr/launchpadlib/find-length
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+33440@code.launchpad.net

Description of the change

This branch fixes launchpadlib to start out with knowledge of all the special resource classes defined by lazr.restfulclient. The most recent launchpadlib release doesn't know about the ScalarValue resource class, because it wasn't specifically mentioned in Launchpad.RESOURCE_TYPE_CLASSES. Now Launchpad.R_T_C is always updated with whatever is in lazr.restful's ServiceRoot.R_T_C.

I added a unit test for this, and also an end-to-end pagetest (for ScalarValue in particular) that must be run in conjunction with Launchpad.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/launchpadlib/NEWS.txt'
--- src/launchpadlib/NEWS.txt 2010-08-17 20:21:12 +0000
+++ src/launchpadlib/NEWS.txt 2010-08-23 19:59:40 +0000
@@ -2,6 +2,11 @@
2NEWS for launchpadlib2NEWS for launchpadlib
3=====================3=====================
44
51.6.5 (2010-08-23)
6==================
7
8- Make launchpadlib compatible with the latest lazr.restfulclient.
9
51.6.4 (2010-08-18)101.6.4 (2010-08-18)
6==================11==================
712
813
=== modified file 'src/launchpadlib/__init__.py'
--- src/launchpadlib/__init__.py 2010-08-17 20:23:54 +0000
+++ src/launchpadlib/__init__.py 2010-08-23 19:59:40 +0000
@@ -14,4 +14,4 @@
14# You should have received a copy of the GNU Lesser General Public License14# You should have received a copy of the GNU Lesser General Public License
15# along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.15# along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
1616
17__version__ = '1.6.4'17__version__ = '1.6.5'
1818
=== added file 'src/launchpadlib/docs/operations.txt'
--- src/launchpadlib/docs/operations.txt 1970-01-01 00:00:00 +0000
+++ src/launchpadlib/docs/operations.txt 2010-08-23 19:59:40 +0000
@@ -0,0 +1,27 @@
1****************
2Named operations
3****************
4
5launchpadlib can transparently determine the size of the list even
6when the size is not directly provided, but is only available through
7a link.
8
9 >>> from launchpadlib.testing.helpers import salgado_with_full_permissions
10 >>> launchpad = salgado_with_full_permissions.login(version="devel")
11
12 >>> results = launchpad.people.find(text='s')
13 >>> 'total_size' in results._wadl_resource.representation.keys()
14 False
15 >>> 'total_size_link' in results._wadl_resource.representation.keys()
16 True
17 >>> len(results) > 1
18 True
19
20Of course, launchpadlib can also determine the size when the size _is_
21directly provided.
22
23 >>> results = launchpad.people.find(text='salgado')
24 >>> 'total_size' in results._wadl_resource.representation.keys()
25 True
26 >>> len(results) == 1
27 True
028
=== modified file 'src/launchpadlib/launchpad.py'
--- src/launchpadlib/launchpad.py 2010-07-14 12:23:11 +0000
+++ src/launchpadlib/launchpad.py 2010-08-23 19:59:40 +0000
@@ -27,7 +27,7 @@
2727
28from lazr.uri import URI28from lazr.uri import URI
29from lazr.restfulclient.resource import (29from lazr.restfulclient.resource import (
30 CollectionWithKeyBasedLookup, HostedFile, ServiceRoot)30 CollectionWithKeyBasedLookup, HostedFile, ScalarValue, ServiceRoot)
31from launchpadlib.credentials import (31from launchpadlib.credentials import (
32 AccessToken, AnonymousAccessToken, Credentials,32 AccessToken, AnonymousAccessToken, Credentials,
33 AuthorizeRequestTokenWithBrowser)33 AuthorizeRequestTokenWithBrowser)
@@ -108,11 +108,11 @@
108 RESOURCE_TYPE_CLASSES = {108 RESOURCE_TYPE_CLASSES = {
109 'bugs': BugSet,109 'bugs': BugSet,
110 'distributions': DistributionSet,110 'distributions': DistributionSet,
111 'HostedFile': HostedFile,
112 'people': PersonSet,111 'people': PersonSet,
113 'project_groups': ProjectGroupSet,112 'project_groups': ProjectGroupSet,
114 'projects': ProjectSet,113 'projects': ProjectSet,
115 }114 }
115 RESOURCE_TYPE_CLASSES.update(ServiceRoot.RESOURCE_TYPE_CLASSES)
116116
117 def __init__(self, credentials, service_root=uris.STAGING_SERVICE_ROOT,117 def __init__(self, credentials, service_root=uris.STAGING_SERVICE_ROOT,
118 cache=None, timeout=None, proxy_info=None,118 cache=None, timeout=None, proxy_info=None,
119119
=== modified file 'src/launchpadlib/tests/test_launchpad.py'
--- src/launchpadlib/tests/test_launchpad.py 2010-07-20 15:56:32 +0000
+++ src/launchpadlib/tests/test_launchpad.py 2010-08-23 19:59:40 +0000
@@ -24,6 +24,8 @@
24import tempfile24import tempfile
25import unittest25import unittest
2626
27from lazr.restfulclient.resource import ServiceRoot
28
27from launchpadlib.credentials import (29from launchpadlib.credentials import (
28 AccessToken, AuthorizeRequestTokenWithBrowser, Credentials)30 AccessToken, AuthorizeRequestTokenWithBrowser, Credentials)
29from launchpadlib.launchpad import Launchpad31from launchpadlib.launchpad import Launchpad
@@ -58,6 +60,16 @@
58 return launchpad60 return launchpad
5961
6062
63class TestResourceTypeClasses(unittest.TestCase):
64 """launchpadlib must know about restfulclient's resource types."""
65
66 def test_resource_types(self):
67 # Make sure that Launchpad knows about every special resource
68 # class defined by lazr.restfulclient.
69 for name, cls in ServiceRoot.RESOURCE_TYPE_CLASSES.items():
70 self.assertEqual(Launchpad.RESOURCE_TYPE_CLASSES[name], cls)
71
72
61class TestNameLookups(unittest.TestCase):73class TestNameLookups(unittest.TestCase):
62 """Test the utility functions in the 'uris' module."""74 """Test the utility functions in the 'uris' module."""
6375

Subscribers

People subscribed via source and target branches