X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=utils%2Ftest%2Ftestapi%2Fopnfv_testapi%2Fresources%2Fpod_handlers.py;h=502988752bb6f41a65711a5f2dafe1416f3c04d4;hb=63fbd31ac218846da13f84ee17ef7a61e159055f;hp=fd9ce3eb57523e1463f9a42e1059e31a3875d626;hpb=b485197b601e77e73690854bc9da6c0428fa5b6a;p=releng.git diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py index fd9ce3eb5..502988752 100644 --- a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py @@ -6,11 +6,9 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import httplib - import handlers +from opnfv_testapi.resources import pod_models from opnfv_testapi.tornado_swagger import swagger -import pod_models class GenericPodHandler(handlers.GenericApiHandler): @@ -42,16 +40,10 @@ class PodCLHandler(GenericPodHandler): @raise 403: pod already exists @raise 400: body or name not provided """ - def query(data): - return {'name': data.name} - - def error(data): - message = '{} already exists as a pod'.format(data.name) - return httplib.FORBIDDEN, message - - miss_checks = ['name'] - db_checks = [(self.table, False, query, error)] - self._create(miss_checks, db_checks) + def query(): + return {'name': self.json_args.get('name')} + miss_fields = ['name'] + self._create(miss_fields=miss_fields, query=query) class PodGURHandler(GenericPodHandler): @@ -63,9 +55,7 @@ class PodGURHandler(GenericPodHandler): @return 200: pod exist @raise 404: pod not exist """ - query = dict() - query['name'] = pod_name - self._get_one(query) + self._get_one(query={'name': pod_name}) def delete(self, pod_name): """ Remove a POD