[TrivialFix] Add negative test in quota detail

Commit [1] does not cover last comments.

Need to add negative test to test new API that should be
available only starting with 2.25 microversion.

And, combine some duplicated code in
manila_tempest_tests/tests/api/test_quotas.py.

[1] I499b099a3ba7704a2108cd15f80ff507e24b7cd0

Change-Id: I8963ad3092e3a78df94c19ea405d48178abef36e
This commit is contained in:
zhongjun2 2017-01-13 11:41:06 +08:00
parent 75e685d40d
commit e7af46c979
2 changed files with 23 additions and 16 deletions

View File

@ -14,6 +14,7 @@
# under the License.
import ddt
import itertools
from tempest import config
from testtools import testcase as tc
@ -65,27 +66,23 @@ class SharesQuotasTest(base.BaseSharesTest):
self.assertGreater(int(quotas["snapshots"]), -2)
self.assertGreater(int(quotas["share_networks"]), -2)
@ddt.data(
*itertools.product(set(("2.25", CONF.share.max_api_microversion)),
(True, False))
)
@ddt.unpack
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_not_supported("2.25")
def test_show_quotas_detail(self):
quotas = self.shares_v2_client.detail_quotas(self.tenant_id)
def test_show_quotas_detail(self, microversion, with_user):
quota_args = {"tenant_id": self.tenant_id, "version": microversion, }
if with_user:
quota_args.update({"user_id": self.user_id})
quotas = self.shares_v2_client.detail_quotas(**quota_args)
quota_keys = list(quotas.keys())
for outer in ('gigabytes', 'snapshot_gigabytes', 'shares',
'snapshots', 'share_networks'):
self.assertIn(outer, quota_keys)
outer_keys = list(quotas[outer].keys())
for inner in ('in_use', 'limit', 'reserved'):
self.assertIn(inner, list(quotas[outer].keys()))
self.assertGreater(int(quotas[outer][inner]), -2)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@base.skip_if_microversion_not_supported("2.25")
def test_show_quotas_detail_for_user(self):
quotas = self.shares_v2_client.detail_quotas(self.tenant_id,
self.user_id)
quota_keys = list(quotas.keys())
for outer in ('gigabytes', 'snapshot_gigabytes', 'shares',
'snapshots', 'share_networks'):
self.assertIn(outer, quota_keys)
for inner in ('in_use', 'limit', 'reserved'):
self.assertIn(inner, list(quotas[outer].keys()))
self.assertIn(inner, outer_keys)
self.assertGreater(int(quotas[outer][inner]), -2)

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import ddt
from tempest import config
from tempest.lib import exceptions as lib_exc
from testtools import testcase as tc
@ -22,6 +23,7 @@ from manila_tempest_tests.tests.api import base
CONF = config.CONF
@ddt.ddt
class SharesQuotasNegativeTest(base.BaseSharesTest):
@classmethod
@ -48,3 +50,11 @@ class SharesQuotasNegativeTest(base.BaseSharesTest):
self.shares_v2_client.update_quotas,
self.shares_v2_client.tenant_id,
shares=9)
@ddt.data("2.6", "2.7", "2.24")
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
def test_get_quotas_detail_with_wrong_version(self, microversion):
self.assertRaises(lib_exc.NotFound,
self.shares_v2_client.detail_quotas,
self.shares_v2_client.tenant_id,
version=microversion)