Adding quota unit test

Change-Id: Ide2b79360ac02d71f9ccf07898601307c673a0a4
This commit is contained in:
Vijendar Komalla 2017-03-13 07:18:18 -05:00 committed by yatin
parent 530d225fcd
commit 37968bbecb
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']]
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.context.make_context")
def test_get_all_admin_not_all_tenants(self, mock_context, mock_policy):