Browse Source

Merge "Adding quota unit test"

changes/53/455353/5
Jenkins 4 years ago
committed by Gerrit Code Review
parent
commit
a3817530b6
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      magnum/tests/unit/api/controllers/v1/test_quota.py

+ 14
- 0
magnum/tests/unit/api/controllers/v1/test_quota.py 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):


Loading…
Cancel
Save