Exemplo n.º 1
0
 def test_create_quota_invalid_hard_limit(self, mock_keystone):
     quota_dict = apiutils.quota_post_data()
     quota_dict['hard_limit'] = -10
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 2
0
 def test_create_quota_invalid_resource(self):
     quota_dict = apiutils.quota_post_data()
     quota_dict['resource'] = 'invalid-res'
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 3
0
 def test_create_quota_invalid_hard_limit(self, mock_keystone):
     quota_dict = apiutils.quota_post_data()
     quota_dict['hard_limit'] = -10
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 4
0
 def test_create_quota(self, mock_keystone, mock_policy):
     mock_policy.return_value = True
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(quota_dict['project_id'], response.json['project_id'])
Exemplo n.º 5
0
 def test_create_quota_no_project_id(self, mock_keystone):
     quota_dict = apiutils.quota_post_data()
     del quota_dict['project_id']
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 6
0
 def test_create_quota_no_project_id(self):
     quota_dict = apiutils.quota_post_data()
     del quota_dict['project_id']
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 7
0
 def test_create_quota_invalid_resource(self):
     quota_dict = apiutils.quota_post_data()
     quota_dict['resource'] = 'invalid-res'
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 8
0
 def test_create_quota(self, mock_keystone, mock_policy):
     mock_policy.return_value = True
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(quota_dict['project_id'], response.json['project_id'])
Exemplo n.º 9
0
 def test_create_quota_project_id_not_found(self, mock_keystone):
     keystone = mock.MagicMock()
     exp = ka_exception.http.NotFound()
     keystone.domain_admin_client.projects .get.side_effect = exp
     mock_keystone.return_value = keystone
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(404, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 10
0
 def test_create_quota_project_id_not_found(self, mock_keystone):
     keystone = mock.MagicMock()
     exp = ka_exception.http.NotFound()
     keystone.domain_admin_client.projects .get.side_effect = exp
     mock_keystone.return_value = keystone
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(404, response.status_int)
     self.assertTrue(response.json['errors'])
Exemplo n.º 11
0
    def test_patch_quota(self):
        quota_dict = apiutils.quota_post_data(hard_limit=5)
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(quota_dict['project_id'], response.json['project_id'])
        self.assertEqual(5, response.json['hard_limit'])

        quota_dict['hard_limit'] = 20
        response = self.patch_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(202, response.status_int)
        self.assertEqual(20, response.json['hard_limit'])
Exemplo n.º 12
0
    def test_patch_quota(self, mock_keystone):
        quota_dict = apiutils.quota_post_data(hard_limit=5)
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)
        self.assertEqual(quota_dict['project_id'], response.json['project_id'])
        self.assertEqual(5, response.json['hard_limit'])

        quota_dict['hard_limit'] = 20
        response = self.patch_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(202, response.status_int)
        self.assertEqual(20, response.json['hard_limit'])
Exemplo n.º 13
0
    def test_patch_quota_not_found(self):
        quota_dict = apiutils.quota_post_data()
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)

        # update quota with non-existing project id
        update_dict = {'project_id': 'not-found',
                       'hard_limit': 20,
                       'resource': 'Cluster'}
        response = self.patch_json('/quotas', update_dict, expect_errors=True)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(404, response.status_int)
        self.assertTrue(response.json['errors'])
Exemplo n.º 14
0
    def test_patch_quota_not_found(self, mock_keystone):
        quota_dict = apiutils.quota_post_data()
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)

        # update quota with non-existing project id
        update_dict = {'project_id': 'not-found',
                       'hard_limit': 20,
                       'resource': 'Cluster'}
        response = self.patch_json('/quotas', update_dict, expect_errors=True)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(404, response.status_int)
        self.assertTrue(response.json['errors'])
Exemplo n.º 15
0
    def test_delete_quota(self):
        quota_dict = apiutils.quota_post_data()
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)

        project_id = quota_dict['project_id']
        resource = quota_dict['resource']
        # delete quota
        self.delete('/quotas/%s/%s' % (project_id, resource))

        # now check that quota does not exist
        response = self.get_json('/quotas/%s/%s' % (project_id, resource),
                                 expect_errors=True)
        self.assertEqual(404, response.status_int)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['errors'])
Exemplo n.º 16
0
    def test_delete_quota(self):
        quota_dict = apiutils.quota_post_data()
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)

        project_id = quota_dict['project_id']
        resource = quota_dict['resource']
        # delete quota
        self.delete('/quotas/%s/%s' % (project_id, resource))

        # now check that quota does not exist
        response = self.get_json(
            '/quotas/%s/%s' % (project_id, resource),
            expect_errors=True)
        self.assertEqual(404, response.status_int)
        self.assertEqual('application/json', response.content_type)
        self.assertTrue(response.json['errors'])
Exemplo n.º 17
0
    def test_delete_quota(self, mock_keystone, mock_policy):
        mock_policy.return_value = True
        quota_dict = apiutils.quota_post_data()
        response = self.post_json('/quotas', quota_dict)
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(201, response.status_int)

        project_id = quota_dict['project_id']
        resource = quota_dict['resource']
        # delete quota
        self.delete('/quotas/%s/%s' % (project_id, resource))

        # now check that quota does not exist
        response = self.get_json('/quotas/%s/%s' % (project_id, resource),
                                 expect_errors=True)
        self.assertEqual(200, response.status_int)
        self.assertEqual('fake_project', response.json['project_id'])
        self.assertEqual(CONF.quotas.max_clusters_per_project,
                         response.json['hard_limit'])
Exemplo n.º 18
0
 def test_quota_init(self):
     quota_dict = apiutils.quota_post_data()
     del quota_dict['hard_limit']
     quota = api_quota.Quota(**quota_dict)
     self.assertEqual(1, quota.hard_limit)
Exemplo n.º 19
0
 def test_create_quota(self):
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(quota_dict['project_id'], response.json['project_id'])
Exemplo n.º 20
0
 def test_quota_init(self):
     quota_dict = apiutils.quota_post_data()
     del quota_dict['hard_limit']
     quota = api_quota.Quota(**quota_dict)
     self.assertEqual(1, quota.hard_limit)
Exemplo n.º 21
0
 def test_create_quota(self):
     quota_dict = apiutils.quota_post_data()
     response = self.post_json('/quotas', quota_dict)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(201, response.status_int)
     self.assertEqual(quota_dict['project_id'], response.json['project_id'])