Files
python-neutronclient/neutronclient/tests/unit/test_quota.py
Kevin Benton 815934c9e1 Allow tenant_id positional in quota syntax
This patch allows tenant_id as a positional argument to the
neutron 'quota-show', 'quota-update', and 'quota-delete' command.
This is helpful because the positional argument is thrown away
by default and the calling tenant ID is used instead so a user
can unexpectedly update or view the wrong quota.

This syntax is still hidden from the help output to encourage the
more explicit --tenant-id syntax.

Closes-Bug: #1524532
Change-Id: I83d4e0763cc8513a5d608a3754f7d46eaa3f1f6b
2015-12-13 16:49:09 -08:00

62 lines
2.3 KiB
Python

#!/usr/bin/env python
# Copyright (C) 2013 Yahoo! Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sys
from neutronclient.common import exceptions
from neutronclient.neutron.v2_0 import quota as test_quota
from neutronclient.tests.unit import test_cli20
class CLITestV20Quota(test_cli20.CLITestV20Base):
def test_show_quota(self):
resource = 'quota'
cmd = test_quota.ShowQuota(
test_cli20.MyApp(sys.stdout), None)
args = ['--tenant-id', self.test_id]
self._test_show_resource(resource, cmd, self.test_id, args)
def test_update_quota(self):
resource = 'quota'
cmd = test_quota.UpdateQuota(
test_cli20.MyApp(sys.stdout), None)
args = ['--tenant-id', self.test_id, '--network', 'test']
self.assertRaises(
exceptions.NeutronClientException, self._test_update_resource,
resource, cmd, self.test_id, args=args,
extrafields={'network': 'new'})
def test_delete_quota_get_parser(self):
cmd = test_cli20.MyApp(sys.stdout)
test_quota.DeleteQuota(cmd, None).get_parser(cmd)
def test_show_quota_positional(self):
resource = 'quota'
cmd = test_quota.ShowQuota(
test_cli20.MyApp(sys.stdout), None)
args = [self.test_id]
self._test_show_resource(resource, cmd, self.test_id, args)
def test_update_quota_positional(self):
resource = 'quota'
cmd = test_quota.UpdateQuota(
test_cli20.MyApp(sys.stdout), None)
args = [self.test_id, '--network', 'test']
self.assertRaises(
exceptions.NeutronClientException, self._test_update_resource,
resource, cmd, self.test_id, args=args,
extrafields={'network': 'new'})