Merge "Adding quota unit test"

This commit is contained in:
Jenkins 2017-04-27 15:54:41 +00:00 committed by Gerrit Code Review
commit a3817530b6
1 changed files with 14 additions and 0 deletions

View File

@ -87,6 +87,20 @@ class TestQuota(api_base.FunctionalTest):
res_proj_ids = [r['project_id'] for r in response['quotas']] res_proj_ids = [r['project_id'] for r in response['quotas']]
self.assertEqual(sorted(expected), sorted(res_proj_ids)) self.assertEqual(sorted(expected), sorted(res_proj_ids))
@mock.patch("magnum.common.policy.enforce")
@mock.patch("magnum.common.context.make_context")
def test_get_all_with_non_admin_context(self, mock_context, mock_policy):
mock_context.return_value = self.context
quota_list = []
for i in range(4):
quota = obj_utils.create_test_quota(self.context,
project_id="proj-id-"+str(i))
quota_list.append(quota)
self.context.is_admin = False
response = self.get_json('/quotas?all_tenants=True')
self.assertEqual(0, len(response['quotas']))
@mock.patch("magnum.common.policy.enforce") @mock.patch("magnum.common.policy.enforce")
@mock.patch("magnum.common.context.make_context") @mock.patch("magnum.common.context.make_context")
def test_get_all_admin_not_all_tenants(self, mock_context, mock_policy): def test_get_all_admin_not_all_tenants(self, mock_context, mock_policy):