diff options
author | TommyLike <tommylikehu@gmail.com> | 2017-05-16 17:22:08 +0800 |
---|---|---|
committer | TommyLike <tommylikehu@gmail.com> | 2017-05-31 11:32:49 +0000 |
commit | a6affea92157a5656ba4beae6ffd059d12e23bdc (patch) | |
tree | c2a99b0c5ebf3cab6701bc45af7be9650a34e3da /cinderclient/tests/unit/test_utils.py | |
parent | 8cd147028f013b1565d2444f63f4944dc7eea1c9 (diff) | |
download | python-cinderclient-a6affea92157a5656ba4beae6ffd059d12e23bdc.tar.gz |
Support generalized resource filter in client
Introduce new command 'list-filters' to retrieve
enabled resource filters.
```
command: cinder list-filters --resource=volume
output:
+----------------+-------------------------------+
| Resource | Filters |
+----------------+-------------------------------+
| volume | name, status, image_metadata |
+----------------+-------------------------------+
```
Also Added new option '--filters' to these list commands:
1. list
2. snapshot-list
3. backup-list
4. attachment-list
5. message-list
6. group-list
7. group-snapshot-list
8. get-pools
Change-Id: I062e6227342ea0d940a8333e84014969c33b49df
Partial: blueprint generalized-filtering-for-cinder-list-resource
Depends-On: 04bd22c1eb371805a3ce9f6c8915325bc0da2d36
Depends-On: 7fdc4688fea373afb85d929e649d311568d1855a
Diffstat (limited to 'cinderclient/tests/unit/test_utils.py')
-rw-r--r-- | cinderclient/tests/unit/test_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py index a62425e..eeb4800 100644 --- a/cinderclient/tests/unit/test_utils.py +++ b/cinderclient/tests/unit/test_utils.py @@ -12,6 +12,7 @@ # limitations under the License. import collections +import ddt import sys import mock @@ -21,6 +22,7 @@ import six from cinderclient import api_versions from cinderclient.apiclient import base as common_base from cinderclient import exceptions +from cinderclient import shell_utils from cinderclient import utils from cinderclient import base from cinderclient.tests.unit import utils as test_utils @@ -187,6 +189,21 @@ class BuildQueryParamTestCase(test_utils.TestCase): self.assertFalse(result_2) +@ddt.ddt +class ExtractFilterTestCase(test_utils.TestCase): + + @ddt.data({'content': ['key1=value1'], + 'expected': {'key1': 'value1'}}, + {'content': ['key1={key2:value2}'], + 'expected': {'key1': {'key2': 'value2'}}}, + {'content': ['key1=value1', 'key2={key22:value22}'], + 'expected': {'key1': 'value1', 'key2': {'key22': 'value22'}}}) + @ddt.unpack + def test_extract_filters(self, content, expected): + result = shell_utils.extract_filters(content) + self.assertEqual(expected, result) + + class PrintListTestCase(test_utils.TestCase): def test_print_list_with_list(self): |