Merge lp:~rackspace-titan/glance/filters-None into lp:~hudson-openstack/glance/trunk

Proposed by Brian Waldon
Status: Merged
Approved by: Rick Harris
Approved revision: 149
Merged at revision: 148
Proposed branch: lp:~rackspace-titan/glance/filters-None
Merge into: lp:~hudson-openstack/glance/trunk
Diff against target: 47 lines (+24/-1)
2 files modified
glance/common/client.py (+7/-1)
tests/unit/test_clients.py (+17/-0)
To merge this branch: bzr merge lp:~rackspace-titan/glance/filters-None
Reviewer Review Type Date Requested Status
Rick Harris (community) Approve
Brian Lamar (community) Approve
Review via email: mp+66212@code.launchpad.net

Description of the change

Prevent query params from being set to None instead of a dict

To post a comment you must log in.
149. By Brian Waldon

removing rogue print

Revision history for this message
Brian Lamar (blamar) wrote :

Approved the one for D2, this is the same fix and same approval for trunk.

Revision history for this message
Brian Lamar (blamar) :
review: Approve
Revision history for this message
Rick Harris (rconradharris) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'glance/common/client.py'
2--- glance/common/client.py 2011-06-28 18:12:26 +0000
3+++ glance/common/client.py 2011-06-28 23:21:49 +0000
4@@ -168,8 +168,14 @@
5 reduced to
6 :retval subset of 'params' dict
7 """
8- result = actual_params.get('filters', {})
9+ try:
10+ # expect 'filters' param to be a dict here
11+ result = dict(actual_params.get('filters'))
12+ except TypeError:
13+ result = {}
14+
15 for allowed_param in allowed_params:
16 if allowed_param in actual_params:
17 result[allowed_param] = actual_params[allowed_param]
18+
19 return result
20
21=== modified file 'tests/unit/test_clients.py'
22--- tests/unit/test_clients.py 2011-06-28 18:12:26 +0000
23+++ tests/unit/test_clients.py 2011-06-28 23:21:49 +0000
24@@ -1191,6 +1191,23 @@
25 for image in images:
26 self.assertEquals('v a', image['properties']['p a'])
27
28+ def test_get_image_bad_filters_with_other_params(self):
29+ """Tests that a detailed call can be filtered by a property"""
30+ extra_fixture = {'id': 3,
31+ 'status': 'saving',
32+ 'is_public': True,
33+ 'disk_format': 'vhd',
34+ 'container_format': 'ovf',
35+ 'name': 'new name! #123',
36+ 'size': 19,
37+ 'checksum': None,
38+ 'properties': {'p a': 'v a'}}
39+
40+ glance.registry.db.api.image_create(None, extra_fixture)
41+
42+ images = self.client.get_images_detailed(filters=None, limit=1)
43+ self.assertEquals(len(images), 1)
44+
45 def test_get_image_meta(self):
46 """Tests that the detailed info about an image returned"""
47 fixture = {'id': 2,

Subscribers

People subscribed via source and target branches