diff options
| author | whoami-rajat <rajatdhasmana@gmail.com> | 2019-08-26 16:55:03 +0530 |
|---|---|---|
| committer | whoami-rajat <rajatdhasmana@gmail.com> | 2019-09-05 18:27:52 +0530 |
| commit | 624b444226a6a5f14d1f381c1ba9301b192510d1 (patch) | |
| tree | 7cecff9b314dea833644c5b273e14d0f1d35e820 /cinderclient/tests | |
| parent | 4bd9000eddfa559ab831df92b7108d15a4b15c87 (diff) | |
| download | python-cinderclient-624b444226a6a5f14d1f381c1ba9301b192510d1.tar.gz | |
Optional filters parameters should be passed only once
This patch does the following :
1) Errors out if similar type of filters args are passed
Eg :
cinder list --name abc --name xyz
cinder list --name abc --filters name=xyz
2) Allows multiple filter parameters of different type
cinder list --filters name=abc --filters size=1
Change-Id: I2f8662555f830b0821147324849d04e7a29d0580
Diffstat (limited to 'cinderclient/tests')
| -rw-r--r-- | cinderclient/tests/unit/test_shell.py | 6 | ||||
| -rw-r--r-- | cinderclient/tests/unit/v3/test_shell.py | 36 |
2 files changed, 41 insertions, 1 deletions
diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index 7050892..55545bc 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -201,6 +201,12 @@ class ShellTest(utils.TestCase): _shell = shell.OpenStackCinderShell() _shell.main(['list']) + def test_duplicate_filters(self): + _shell = shell.OpenStackCinderShell() + self.assertRaises(exceptions.CommandError, + _shell.main, + ['list', '--name', 'abc', '--filters', 'name=xyz']) + @unittest.skip("Skip cuz I broke it") def test_cinder_service_name(self): # Failing with 'No mock address' means we are not diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index f4aa598..8c81de0 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -145,6 +145,10 @@ class ShellTest(utils.TestCase): u'list --filters name~=Σ', 'expected': '/volumes/detail?name~=%CE%A3'}, + {'command': + u'list --filters name=abc --filters size=1', + 'expected': + '/volumes/detail?name=abc&size=1'}, # testcases for list group {'command': 'group-list --filters name=456', @@ -158,6 +162,10 @@ class ShellTest(utils.TestCase): 'group-list --filters name~=456', 'expected': '/groups/detail?name~=456'}, + {'command': + 'group-list --filters name=abc --filters status=available', + 'expected': + '/groups/detail?name=abc&status=available'}, # testcases for list group-snapshot {'command': 'group-snapshot-list --status=error --filters status=available', @@ -171,6 +179,11 @@ class ShellTest(utils.TestCase): 'group-snapshot-list --filters status~=available', 'expected': '/group_snapshots/detail?status~=available'}, + {'command': + 'group-snapshot-list --filters status=available ' + '--filters availability_zone=123', + 'expected': + '/group_snapshots/detail?availability_zone=123&status=available'}, # testcases for list message {'command': 'message-list --event_id=123 --filters event_id=456', @@ -184,6 +197,10 @@ class ShellTest(utils.TestCase): 'message-list --filters request_id~=123', 'expected': '/messages?request_id~=123'}, + {'command': + 'message-list --filters request_id=123 --filters event_id=456', + 'expected': + '/messages?event_id=456&request_id=123'}, # testcases for list attachment {'command': 'attachment-list --volume-id=123 --filters volume_id=456', @@ -197,6 +214,11 @@ class ShellTest(utils.TestCase): 'attachment-list --filters volume_id~=456', 'expected': '/attachments?volume_id~=456'}, + {'command': + 'attachment-list --filters volume_id=123 ' + '--filters mountpoint=456', + 'expected': + '/attachments?mountpoint=456&volume_id=123'}, # testcases for list backup {'command': 'backup-list --volume-id=123 --filters volume_id=456', @@ -210,6 +232,10 @@ class ShellTest(utils.TestCase): 'backup-list --filters volume_id~=456', 'expected': '/backups/detail?volume_id~=456'}, + {'command': + 'backup-list --filters volume_id=123 --filters name=456', + 'expected': + '/backups/detail?name=456&volume_id=123'}, # testcases for list snapshot {'command': 'snapshot-list --volume-id=123 --filters volume_id=456', @@ -223,6 +249,10 @@ class ShellTest(utils.TestCase): 'snapshot-list --filters volume_id~=456', 'expected': '/snapshots/detail?volume_id~=456'}, + {'command': + 'snapshot-list --filters volume_id=123 --filters name=456', + 'expected': + '/snapshots/detail?name=456&volume_id=123'}, # testcases for get pools {'command': 'get-pools --filters name=456 --detail', @@ -231,7 +261,11 @@ class ShellTest(utils.TestCase): {'command': 'get-pools --filters name=456', 'expected': - '/scheduler-stats/get_pools?name=456'} + '/scheduler-stats/get_pools?name=456'}, + {'command': + 'get-pools --filters name=456 --filters detail=True', + 'expected': + '/scheduler-stats/get_pools?detail=True&name=456'} ) @ddt.unpack def test_list_with_filters_mixed(self, command, expected): |
