diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2015-01-21 15:02:58 -0600 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2015-01-27 19:17:35 -0600 |
| commit | 61a40343fdbb89a1c6404ab03fcfd84daee31c9e (patch) | |
| tree | 8b34e7f8ba5d26a911023cc447308c21e7dcd612 /openstackclient/tests/image/v1 | |
| parent | 2c03f6f42fc17ca145e527cc87a7c2e7043e32c7 (diff) | |
| download | python-openstackclient-61a40343fdbb89a1c6404ab03fcfd84daee31c9e.tar.gz | |
Add filter to image list
* Hides previously broken --page-size option
* Adds --property to image list for filtering on properties
* Adds Visibility, Protected, Owner, Properties/Tags to --long output
* Adds api.utils.simple_filter() for selecting matches out of a list
of objects
* Adds tests for all of the above
* Updates image docs
There are additional filtering options to be added in later reviews.
Change-Id: I32feff0ad61aae749b33621c817658d7dc90c3aa
Closes-bug: 1401902
Diffstat (limited to 'openstackclient/tests/image/v1')
| -rw-r--r-- | openstackclient/tests/image/v1/test_image.py | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/openstackclient/tests/image/v1/test_image.py b/openstackclient/tests/image/v1/test_image.py index 88809966..355f8c82 100644 --- a/openstackclient/tests/image/v1/test_image.py +++ b/openstackclient/tests/image/v1/test_image.py @@ -407,8 +407,18 @@ class TestImageList(TestImage): detailed=True, ) - collist = ('ID', 'Name', 'Disk Format', 'Container Format', - 'Size', 'Status') + collist = ( + 'ID', + 'Name', + 'Disk Format', + 'Container Format', + 'Size', + 'Status', + 'Visibility', + 'Protected', + 'Owner', + 'Properties', + ) self.assertEqual(collist, columns) datalist = (( @@ -418,6 +428,45 @@ class TestImageList(TestImage): '', '', '', + 'public', + False, + image_fakes.image_owner, + "Alpha='a', Beta='b', Gamma='g'", + ), ) + self.assertEqual(datalist, tuple(data)) + + @mock.patch('openstackclient.api.utils.simple_filter') + def test_image_list_property_option(self, sf_mock): + sf_mock.return_value = [ + copy.deepcopy(image_fakes.IMAGE), + ] + + arglist = [ + '--property', 'a=1', + ] + verifylist = [ + ('property', {'a': '1'}), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # DisplayCommandBase.take_action() returns two tuples + columns, data = self.cmd.take_action(parsed_args) + self.api_mock.image_list.assert_called_with( + detailed=True, + ) + sf_mock.assert_called_with( + [image_fakes.IMAGE], + attr='a', + value='1', + property_field='properties', + ) + + collist = ('ID', 'Name') + + self.assertEqual(columns, collist) + datalist = (( + image_fakes.image_id, + image_fakes.image_name, ), ) self.assertEqual(datalist, tuple(data)) |
