summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2017-05-11 10:26:59 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-05-11 10:26:59 +0000
commitaa7d754bebbf6b20e6a14609372bf36a9059a269 (patch)
tree3f0057eec97e75056af65837db6e4421a87424b9 /utils
parent858fada30fc828dc0caaae3b13eea4b8c445fadb (diff)
parent2458c2bfaae2cdd37dbc4d8fb88e45645c2baf57 (diff)
Merge "correct the import impl of TestAPI"
Diffstat (limited to 'utils')
-rw-r--r--utils/test/testapi/opnfv_testapi/common/check.py6
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/handlers.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/models.py3
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/pod_handlers.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/pod_models.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/project_handlers.py4
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/project_models.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/result_models.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/testcase_models.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py37
-rw-r--r--utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py23
-rw-r--r--utils/test/testapi/opnfv_testapi/tornado_swagger/views.py21
13 files changed, 55 insertions, 53 deletions
diff --git a/utils/test/testapi/opnfv_testapi/common/check.py b/utils/test/testapi/opnfv_testapi/common/check.py
index be4b1df12..4d9902cd0 100644
--- a/utils/test/testapi/opnfv_testapi/common/check.py
+++ b/utils/test/testapi/opnfv_testapi/common/check.py
@@ -8,9 +8,11 @@
##############################################################################
import functools
-from tornado import web, gen
+from tornado import gen
+from tornado import web
-from opnfv_testapi.common import raises, message
+from opnfv_testapi.common import message
+from opnfv_testapi.common import raises
def authenticate(method):
diff --git a/utils/test/testapi/opnfv_testapi/resources/handlers.py b/utils/test/testapi/opnfv_testapi/resources/handlers.py
index 955fbbef7..dbf94eb75 100644
--- a/utils/test/testapi/opnfv_testapi/resources/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/handlers.py
@@ -26,10 +26,10 @@ import json
from tornado import gen
from tornado import web
-import models
from opnfv_testapi.common import check
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
DEFAULT_REPRESENTATION = "application/json"
diff --git a/utils/test/testapi/opnfv_testapi/resources/models.py b/utils/test/testapi/opnfv_testapi/resources/models.py
index 0ea482fd2..e8fc532b7 100644
--- a/utils/test/testapi/opnfv_testapi/resources/models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/models.py
@@ -14,9 +14,8 @@
# feng.xiaowei@zte.com.cn mv TestResut to result_models.py 5-23-2016
# feng.xiaowei@zte.com.cn add ModelBase 12-20-2016
##############################################################################
-import copy
import ast
-
+import copy
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py
index e21841d33..502988752 100644
--- a/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/pod_handlers.py
@@ -7,8 +7,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import handlers
+from opnfv_testapi.resources import pod_models
from opnfv_testapi.tornado_swagger import swagger
-import pod_models
class GenericPodHandler(handlers.GenericApiHandler):
diff --git a/utils/test/testapi/opnfv_testapi/resources/pod_models.py b/utils/test/testapi/opnfv_testapi/resources/pod_models.py
index 26a9e6788..2c3ea978b 100644
--- a/utils/test/testapi/opnfv_testapi/resources/pod_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/pod_models.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import models
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py
index d79cd3b61..be2950705 100644
--- a/utils/test/testapi/opnfv_testapi/resources/project_handlers.py
+++ b/utils/test/testapi/opnfv_testapi/resources/project_handlers.py
@@ -7,9 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import handlers
+from opnfv_testapi.resources import handlers
+from opnfv_testapi.resources import project_models
from opnfv_testapi.tornado_swagger import swagger
-import project_models
class GenericProjectHandler(handlers.GenericApiHandler):
diff --git a/utils/test/testapi/opnfv_testapi/resources/project_models.py b/utils/test/testapi/opnfv_testapi/resources/project_models.py
index f7323c1c4..3243882bd 100644
--- a/utils/test/testapi/opnfv_testapi/resources/project_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/project_models.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import models
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/resources/result_models.py b/utils/test/testapi/opnfv_testapi/resources/result_models.py
index 50445fc22..62a6dacff 100644
--- a/utils/test/testapi/opnfv_testapi/resources/result_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/result_models.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import models
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index b84accf4d..467cff241 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -1,4 +1,4 @@
-import models
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
index 9b8f4b5ff..2379dfc4c 100644
--- a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import models
+from opnfv_testapi.resources import models
from opnfv_testapi.tornado_swagger import swagger
diff --git a/utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py b/utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py
index af0b515ad..72add2d64 100644
--- a/utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py
+++ b/utils/test/testapi/opnfv_testapi/tornado_swagger/handlers.py
@@ -6,38 +6,37 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from tornado.web import URLSpec, StaticFileHandler
+import tornado.web
-from settings import default_settings, \
- SWAGGER_API_DOCS, SWAGGER_RESOURCE_LISTING, SWAGGER_API_DECLARATION
-from views import SwaggerUIHandler, SwaggerResourcesHandler, SwaggerApiHandler
+from opnfv_testapi.tornado_swagger import settings
+from opnfv_testapi.tornado_swagger import views
def swagger_handlers():
- prefix = default_settings.get('swagger_prefix', '/swagger')
+ prefix = settings.default_settings.get('swagger_prefix', '/swagger')
if prefix[-1] != '/':
prefix += '/'
def _path(suffix):
return prefix + suffix
return [
- URLSpec(
+ tornado.web.URLSpec(
_path(r'spec.html$'),
- SwaggerUIHandler,
- default_settings,
- name=SWAGGER_API_DOCS),
- URLSpec(
+ views.SwaggerUIHandler,
+ settings.default_settings,
+ name=settings.SWAGGER_API_DOCS),
+ tornado.web.URLSpec(
_path(r'resources.json$'),
- SwaggerResourcesHandler,
- default_settings,
- name=SWAGGER_RESOURCE_LISTING),
- URLSpec(
+ views.SwaggerResourcesHandler,
+ settings.default_settings,
+ name=settings.SWAGGER_RESOURCE_LISTING),
+ tornado.web.URLSpec(
_path(r'APIs$'),
- SwaggerApiHandler,
- default_settings,
- name=SWAGGER_API_DECLARATION),
+ views.SwaggerApiHandler,
+ settings.default_settings,
+ name=settings.SWAGGER_API_DECLARATION),
(
_path(r'(.*\.(css|png|gif|js))'),
- StaticFileHandler,
- {'path': default_settings.get('static_path')}),
+ tornado.web.StaticFileHandler,
+ {'path': settings.default_settings.get('static_path')}),
]
diff --git a/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py b/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
index 3d21edefb..a0f6ae70c 100644
--- a/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
+++ b/utils/test/testapi/opnfv_testapi/tornado_swagger/swagger.py
@@ -6,15 +6,15 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import inspect
-from functools import wraps
from HTMLParser import HTMLParser
+from functools import wraps
+import inspect
import epydoc.markup
import tornado.web
-from settings import default_settings, models
-from handlers import swagger_handlers
+from opnfv_testapi.tornado_swagger import handlers
+from opnfv_testapi.tornado_swagger import settings
class EpytextParser(HTMLParser):
@@ -204,7 +204,7 @@ class model(DocParser):
if '__init__' in dir(cls):
self._parse_args(cls.__init__)
self.parse_docstring(inspect.getdoc(cls))
- models.append(self)
+ settings.models.append(self)
def _parse_args(self, func):
argspec = inspect.getargspec(func)
@@ -276,15 +276,16 @@ class operation(DocParser):
def docs(**opts):
- default_settings.update(opts)
+ settings.default_settings.update(opts)
class Application(tornado.web.Application):
- def __init__(self, handlers=None,
+ def __init__(self, app_handlers=None,
default_host="",
transforms=None,
**settings):
- super(Application, self).__init__(swagger_handlers() + handlers,
- default_host,
- transforms,
- **settings)
+ super(Application, self).__init__(
+ handlers.swagger_handlers() + app_handlers,
+ default_host,
+ transforms,
+ **settings)
diff --git a/utils/test/testapi/opnfv_testapi/tornado_swagger/views.py b/utils/test/testapi/opnfv_testapi/tornado_swagger/views.py
index 2168c5e91..591cb44e7 100644
--- a/utils/test/testapi/opnfv_testapi/tornado_swagger/views.py
+++ b/utils/test/testapi/opnfv_testapi/tornado_swagger/views.py
@@ -8,13 +8,12 @@
##############################################################################
import inspect
import json
+import os.path
import tornado.template
import tornado.web
-from settings import SWAGGER_VERSION
-from settings import SWAGGER_RESOURCE_LISTING, SWAGGER_API_DECLARATION
-from settings import models, basePath
+from opnfv_testapi.tornado_swagger import settings
def json_dumps(obj, pretty=False):
@@ -30,7 +29,9 @@ class SwaggerUIHandler(tornado.web.RequestHandler):
return self.static_path
def get(self):
- discovery_url = basePath() + self.reverse_url(SWAGGER_RESOURCE_LISTING)
+ discovery_url = os.path.join(
+ settings.basePath(),
+ self.reverse_url(settings.SWAGGER_RESOURCE_LISTING))
self.render('index.html', discovery_url=discovery_url)
@@ -43,12 +44,12 @@ class SwaggerResourcesHandler(tornado.web.RequestHandler):
self.set_header('content-type', 'application/json')
resources = {
'apiVersion': self.api_version,
- 'swaggerVersion': SWAGGER_VERSION,
- 'basePath': basePath(),
+ 'swaggerVersion': settings.SWAGGER_VERSION,
+ 'basePath': settings.basePath(),
'produces': ["application/json"],
'description': 'Test Api Spec',
'apis': [{
- 'path': self.reverse_url(SWAGGER_API_DECLARATION),
+ 'path': self.reverse_url(settings.SWAGGER_API_DECLARATION),
'description': 'Test Api Spec'
}]
}
@@ -69,11 +70,11 @@ class SwaggerApiHandler(tornado.web.RequestHandler):
specs = {
'apiVersion': self.api_version,
- 'swaggerVersion': SWAGGER_VERSION,
- 'basePath': basePath(),
+ 'swaggerVersion': settings.SWAGGER_VERSION,
+ 'basePath': settings.basePath(),
'apis': [self.__get_api_spec__(path, spec, operations)
for path, spec, operations in apis],
- 'models': self.__get_models_spec(models)
+ 'models': self.__get_models_spec(settings.models)
}
self.finish(json_dumps(specs, self.get_arguments('pretty')))