diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-12 21:30:58 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-12 21:30:58 +0000 |
| commit | 95639d4e734de11d49b8fb8f299979fa79df83bc (patch) | |
| tree | c52b7d9afc0faaf67c49055c8c684090cf898dd3 | |
| parent | 47f827d8a5a0a14c54e72f0a1c76768e55095964 (diff) | |
| parent | 060057c5840949abcb5eea3b2b424bf4e5c8df5a (diff) | |
| download | python-neutronclient-95639d4e734de11d49b8fb8f299979fa79df83bc.tar.gz | |
Merge "deal with -c option when the list result is empty."
| -rwxr-xr-x | quantum_test.sh | 4 | ||||
| -rw-r--r-- | quantumclient/quantum/v2_0/__init__.py | 2 | ||||
| -rw-r--r-- | quantumclient/tests/unit/test_cli20_network.py | 30 |
3 files changed, 35 insertions, 1 deletions
diff --git a/quantum_test.sh b/quantum_test.sh index 19fe390..b2e4093 100755 --- a/quantum_test.sh +++ b/quantum_test.sh @@ -32,6 +32,8 @@ quantum net-show $network_id || die "fail to show network $network_id" quantum net-update $network --admin_state_up False || die "fail to update network $network" quantum net-update $network_id --admin_state_up True || die "fail to update network $network_id" +quantum net-list -c id -- --id fakeid || die "fail to list networks with column selection on empty list" + # test the CRUD of subnet subnet=mysubnet1 cidr=10.0.1.3/24 @@ -122,4 +124,4 @@ else die "without valid context on server, quota delete command should fail." fi quantum quota-list || die "fail to update quota for self" -fi
\ No newline at end of file +fi diff --git a/quantumclient/quantum/v2_0/__init__.py b/quantumclient/quantum/v2_0/__init__.py index 5de594b..78c5339 100644 --- a/quantumclient/quantum/v2_0/__init__.py +++ b/quantumclient/quantum/v2_0/__init__.py @@ -362,6 +362,8 @@ class ListCommand(QuantumCommand, lister.Lister): if collection in data: info = data[collection] _columns = len(info) > 0 and sorted(info[0].keys()) or [] + if not _columns: + parsed_args.columns = [] return (_columns, (utils.get_item_properties( s, _columns, formatters=self._formatters, ) for s in info), ) diff --git a/quantumclient/tests/unit/test_cli20_network.py b/quantumclient/tests/unit/test_cli20_network.py index 16837b3..de627de 100644 --- a/quantumclient/tests/unit/test_cli20_network.py +++ b/quantumclient/tests/unit/test_cli20_network.py @@ -18,6 +18,7 @@ import sys from quantumclient.common import exceptions +from quantumclient.tests.unit import test_cli20 from quantumclient.tests.unit.test_cli20 import CLITestV20Base from quantumclient.tests.unit.test_cli20 import MyApp from quantumclient.quantum.v2_0.network import CreateNetwork @@ -79,6 +80,35 @@ class CLITestV20Network(CLITestV20Base): position_names, position_values, admin_state_up=False) + def test_lsit_nets_empty_with_column(self): + resources = "networks" + cmd = ListNetwork(MyApp(sys.stdout), None) + self.mox.StubOutWithMock(cmd, "get_client") + self.mox.StubOutWithMock(self.client.httpclient, "request") + cmd.get_client().MultipleTimes().AndReturn(self.client) + reses = {resources: []} + resstr = self.client.serialize(reses) + # url method body + query = "id=myfakeid" + args = ['-c', 'id', '--', '--id', 'myfakeid'] + path = getattr(self.client, resources + "_path") + self.client.httpclient.request( + test_cli20.end_url(path, query), 'GET', + body=None, + headers=test_cli20.ContainsKeyValue( + 'X-Auth-Token', + test_cli20.TOKEN)).AndReturn( + (test_cli20.MyResp(200), resstr)) + self.mox.ReplayAll() + cmd_parser = cmd.get_parser("list_" + resources) + + parsed_args = cmd_parser.parse_args(args) + cmd.run(parsed_args) + self.mox.VerifyAll() + self.mox.UnsetStubs() + _str = self.fake_stdout.make_string() + self.assertEquals('\n', _str) + def test_list_nets_detail(self): """list nets: -D.""" resources = "networks" |
