Merge "Use String for Project ID in schema"

This commit is contained in:
Jenkins 2017-02-22 19:00:03 +00:00 committed by Gerrit Code Review
commit f398eb8fc7
3 changed files with 22 additions and 19 deletions

View File

@ -15,14 +15,8 @@ class Projects(base.Resource):
@base.pagination_context
def get(self, context, request_args, pagination_params):
"""Get all projects. Requires super admin privileges."""
project_id = request_args["id"]
project_name = request_args["name"]
if project_id:
project_obj = dbapi.projects_get_by_id(context, project_id)
projects_obj = [project_obj]
link_params = {}
if project_name:
projects_obj, link_params = dbapi.projects_get_by_name(
context, project_name, request_args, pagination_params,

View File

@ -381,7 +381,7 @@ DefinitionProject = {
"type": "string",
},
"id": {
"type": "integer",
"type": "string",
},
"name": {
"type": "string",
@ -1032,11 +1032,6 @@ validators = {
"args": {
"additionalProperties": False,
"properties": {
"id": {
"default": None,
"type": "integer",
"description": "id of the project to get",
},
"name": {
"default": None,
"type": "string",
@ -1050,7 +1045,7 @@ validators = {
"description": "Number of projects to return in a page",
},
"marker": {
"type": "integer",
"type": "string",
"description": "Last project ID of the previous page",
},
"vars": {

View File

@ -1,5 +1,7 @@
import copy
from oslo_utils import uuidutils
from craton.tests import functional
from craton.tests.functional.test_variable_calls import \
APIV1ResourceWithVariablesTestCase
@ -23,15 +25,17 @@ class ProjectTests(functional.TestCase):
payload = {'name': name}
if variables:
payload['variables'] = variables
project = self.post(url, headers=self.root_headers, data=payload)
self.assertEqual(201, project.status_code)
self.assertIn('Location', project.headers)
response = self.post(url, headers=self.root_headers, data=payload)
self.assertEqual(201, response.status_code)
self.assertIn('Location', response.headers)
project = response.json()
self.assertTrue(uuidutils.is_uuid_like(project['id']))
self.assertEqual(
project.headers['Location'],
"{}/{}".format(url, project.json()['id'])
response.headers['Location'],
"{}/{}".format(url, project['id'])
)
return project.json()
return project
class TestPaginationOfProjects(ProjectTests):
@ -51,6 +55,16 @@ class TestPaginationOfProjects(ProjectTests):
projects = json['projects']
self.assertEqual(30, len(projects))
def test_lists_projects_with_the_same_name(self):
self.create_project('project-0')
response = self.get(self.url + '/v1/projects',
name='project-0',
headers=self.root_headers)
self.assertSuccessOk(response)
projects = response.json()['projects']
self.assertEqual(2, len(projects))
class APIV1ProjectTest(ProjectTests, APIV1ResourceWithVariablesTestCase):