summaryrefslogtreecommitdiffstats
path: root/testapi
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-10-27 16:28:48 +0800
committerSerena Feng <feng.xiaowei@zte.com.cn>2017-10-27 09:00:26 +0000
commit9db91e3b166f07750a045d5e24f820837f5772b4 (patch)
tree48afa8a00bdb99cc656fc3ad87bbf006a0288a71 /testapi
parenta9da6ed15e08b2797f5c794117327d40b46bceae (diff)
divide resources into handlers and models
divide resources into handlers&models put ui handlers into handlers directory put User into user_models.py Change-Id: I3d9e260097205213c3ea8d4eac08b9019e017f71 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi')
-rw-r--r--testapi/opnfv_testapi/handlers/__init__.py (renamed from testapi/opnfv_testapi/tests/unit/resources/__init__.py)0
-rw-r--r--testapi/opnfv_testapi/handlers/base_handlers.py (renamed from testapi/opnfv_testapi/resources/handlers.py)6
-rw-r--r--testapi/opnfv_testapi/handlers/pod_handlers.py (renamed from testapi/opnfv_testapi/resources/pod_handlers.py)6
-rw-r--r--testapi/opnfv_testapi/handlers/project_handlers.py (renamed from testapi/opnfv_testapi/resources/project_handlers.py)6
-rw-r--r--testapi/opnfv_testapi/handlers/result_handlers.py (renamed from testapi/opnfv_testapi/resources/result_handlers.py)10
-rw-r--r--testapi/opnfv_testapi/handlers/root_handlers.py (renamed from testapi/opnfv_testapi/ui/root.py)4
-rw-r--r--testapi/opnfv_testapi/handlers/scenario_handlers.py (renamed from testapi/opnfv_testapi/resources/scenario_handlers.py)6
-rw-r--r--testapi/opnfv_testapi/handlers/sign_handlers.py (renamed from testapi/opnfv_testapi/ui/auth/sign.py)4
-rw-r--r--testapi/opnfv_testapi/handlers/testcase_handlers.py (renamed from testapi/opnfv_testapi/resources/testcase_handlers.py)6
-rw-r--r--testapi/opnfv_testapi/handlers/user_handlers.py (renamed from testapi/opnfv_testapi/ui/auth/user.py)14
-rw-r--r--testapi/opnfv_testapi/models/__init__.py (renamed from testapi/opnfv_testapi/resources/__init__.py)0
-rw-r--r--testapi/opnfv_testapi/models/base_models.py (renamed from testapi/opnfv_testapi/resources/models.py)0
-rw-r--r--testapi/opnfv_testapi/models/pod_models.py (renamed from testapi/opnfv_testapi/resources/pod_models.py)8
-rw-r--r--testapi/opnfv_testapi/models/project_models.py (renamed from testapi/opnfv_testapi/resources/project_models.py)10
-rw-r--r--testapi/opnfv_testapi/models/result_models.py (renamed from testapi/opnfv_testapi/resources/result_models.py)14
-rw-r--r--testapi/opnfv_testapi/models/scenario_models.py (renamed from testapi/opnfv_testapi/resources/scenario_models.py)22
-rw-r--r--testapi/opnfv_testapi/models/testcase_models.py (renamed from testapi/opnfv_testapi/resources/testcase_models.py)10
-rw-r--r--testapi/opnfv_testapi/models/user_models.py9
-rw-r--r--testapi/opnfv_testapi/router/url_mappings.py31
-rw-r--r--testapi/opnfv_testapi/tests/unit/executor.py2
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/__init__.py (renamed from testapi/opnfv_testapi/ui/__init__.py)0
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json (renamed from testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json)0
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json (renamed from testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json)0
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_base.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_base.py)6
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_pod.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_pod.py)4
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_project.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_project.py)4
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_result.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_result.py)8
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_scenario.py)4
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_testcase.py)6
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_token.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_token.py)2
-rw-r--r--testapi/opnfv_testapi/tests/unit/handlers/test_version.py (renamed from testapi/opnfv_testapi/tests/unit/resources/test_version.py)6
-rw-r--r--testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py123
-rw-r--r--testapi/opnfv_testapi/tornado_swagger/handlers.py2
-rw-r--r--testapi/opnfv_testapi/ui/auth/__init__.py0
34 files changed, 106 insertions, 227 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/resources/__init__.py b/testapi/opnfv_testapi/handlers/__init__.py
index e69de29..e69de29 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/__init__.py
+++ b/testapi/opnfv_testapi/handlers/__init__.py
diff --git a/testapi/opnfv_testapi/resources/handlers.py b/testapi/opnfv_testapi/handlers/base_handlers.py
index 6c7a819..a8ee3db 100644
--- a/testapi/opnfv_testapi/resources/handlers.py
+++ b/testapi/opnfv_testapi/handlers/base_handlers.py
@@ -20,8 +20,8 @@
# feng.xiaowei@zte.com.cn remove DashboardHandler 5-30-2016
##############################################################################
-import json
from datetime import datetime
+import json
from tornado import gen
from tornado import web
@@ -30,7 +30,7 @@ from opnfv_testapi.common import check
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
from opnfv_testapi.db import api as dbapi
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
DEFAULT_REPRESENTATION = "application/json"
@@ -67,7 +67,7 @@ class GenericApiHandler(web.RequestHandler):
def _create_response(self, resource):
href = self.request.full_url() + '/' + str(resource)
- return models.CreateResponse(href=href).format()
+ return base_models.CreateResponse(href=href).format()
def format_data(self, data):
cls_data = self.table_cls.from_dict(data)
diff --git a/testapi/opnfv_testapi/resources/pod_handlers.py b/testapi/opnfv_testapi/handlers/pod_handlers.py
index 5029887..abf5bf9 100644
--- a/testapi/opnfv_testapi/resources/pod_handlers.py
+++ b/testapi/opnfv_testapi/handlers/pod_handlers.py
@@ -6,12 +6,12 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import handlers
-from opnfv_testapi.resources import pod_models
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.models import pod_models
from opnfv_testapi.tornado_swagger import swagger
-class GenericPodHandler(handlers.GenericApiHandler):
+class GenericPodHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(GenericPodHandler, self).__init__(application, request, **kwargs)
self.table = 'pods'
diff --git a/testapi/opnfv_testapi/resources/project_handlers.py b/testapi/opnfv_testapi/handlers/project_handlers.py
index be29507..30d9ab3 100644
--- a/testapi/opnfv_testapi/resources/project_handlers.py
+++ b/testapi/opnfv_testapi/handlers/project_handlers.py
@@ -7,12 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import handlers
-from opnfv_testapi.resources import project_models
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.models import project_models
from opnfv_testapi.tornado_swagger import swagger
-class GenericProjectHandler(handlers.GenericApiHandler):
+class GenericProjectHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(GenericProjectHandler, self).__init__(application,
request,
diff --git a/testapi/opnfv_testapi/resources/result_handlers.py b/testapi/opnfv_testapi/handlers/result_handlers.py
index 4cd533c..c4b61ff 100644
--- a/testapi/opnfv_testapi/resources/result_handlers.py
+++ b/testapi/opnfv_testapi/handlers/result_handlers.py
@@ -6,23 +6,23 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+from datetime import datetime
+from datetime import timedelta
import json
import logging
from bson import objectid
-from datetime import datetime
-from datetime import timedelta
from opnfv_testapi.common import constants
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
from opnfv_testapi.common.config import CONF
-from opnfv_testapi.resources import handlers
-from opnfv_testapi.resources import result_models
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.models import result_models
from opnfv_testapi.tornado_swagger import swagger
-class GenericResultHandler(handlers.GenericApiHandler):
+class GenericResultHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(GenericResultHandler, self).__init__(application,
request,
diff --git a/testapi/opnfv_testapi/ui/root.py b/testapi/opnfv_testapi/handlers/root_handlers.py
index 286a6b0..92920fa 100644
--- a/testapi/opnfv_testapi/ui/root.py
+++ b/testapi/opnfv_testapi/handlers/root_handlers.py
@@ -1,8 +1,8 @@
from opnfv_testapi.common.config import CONF
-from opnfv_testapi.resources import handlers
+from opnfv_testapi.handlers import base_handlers
-class RootHandler(handlers.GenericApiHandler):
+class RootHandler(base_handlers.GenericApiHandler):
def get_template_path(self):
return CONF.ui_static_path
diff --git a/testapi/opnfv_testapi/resources/scenario_handlers.py b/testapi/opnfv_testapi/handlers/scenario_handlers.py
index e9c19a7..67abcff 100644
--- a/testapi/opnfv_testapi/resources/scenario_handlers.py
+++ b/testapi/opnfv_testapi/handlers/scenario_handlers.py
@@ -2,12 +2,12 @@ import functools
from opnfv_testapi.common import message
from opnfv_testapi.common import raises
-from opnfv_testapi.resources import handlers
-import opnfv_testapi.resources.scenario_models as models
+from opnfv_testapi.handlers import base_handlers
+import opnfv_testapi.models.scenario_models as models
from opnfv_testapi.tornado_swagger import swagger
-class GenericScenarioHandler(handlers.GenericApiHandler):
+class GenericScenarioHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(GenericScenarioHandler, self).__init__(application,
request,
diff --git a/testapi/opnfv_testapi/ui/auth/sign.py b/testapi/opnfv_testapi/handlers/sign_handlers.py
index 318473e..7540662 100644
--- a/testapi/opnfv_testapi/ui/auth/sign.py
+++ b/testapi/opnfv_testapi/handlers/sign_handlers.py
@@ -5,10 +5,10 @@ from tornado import web
from opnfv_testapi.common import constants
from opnfv_testapi.common.config import CONF
from opnfv_testapi.db import api as dbapi
-from opnfv_testapi.resources import handlers
+from opnfv_testapi.handlers import base_handlers
-class SignBaseHandler(handlers.GenericApiHandler):
+class SignBaseHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(SignBaseHandler, self).__init__(application, request, **kwargs)
self.table = 'users'
diff --git a/testapi/opnfv_testapi/resources/testcase_handlers.py b/testapi/opnfv_testapi/handlers/testcase_handlers.py
index 9399326..c4c3c21 100644
--- a/testapi/opnfv_testapi/resources/testcase_handlers.py
+++ b/testapi/opnfv_testapi/handlers/testcase_handlers.py
@@ -7,12 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import handlers
-from opnfv_testapi.resources import testcase_models
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.models import testcase_models
from opnfv_testapi.tornado_swagger import swagger
-class GenericTestcaseHandler(handlers.GenericApiHandler):
+class GenericTestcaseHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(GenericTestcaseHandler, self).__init__(application,
request,
diff --git a/testapi/opnfv_testapi/ui/auth/user.py b/testapi/opnfv_testapi/handlers/user_handlers.py
index ff2c2a9..5067e35 100644
--- a/testapi/opnfv_testapi/ui/auth/user.py
+++ b/testapi/opnfv_testapi/handlers/user_handlers.py
@@ -1,19 +1,11 @@
from opnfv_testapi.common import constants
from opnfv_testapi.common import raises
from opnfv_testapi.common.config import CONF
-from opnfv_testapi.resources import handlers
-from opnfv_testapi.resources import models
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.models.user_models import User
-class User(models.ModelBase):
- def __init__(self, user=None, email=None, fullname=None, groups=None):
- self.user = user
- self.email = email
- self.fullname = fullname
- self.groups = groups
-
-
-class UserHandler(handlers.GenericApiHandler):
+class UserHandler(base_handlers.GenericApiHandler):
def __init__(self, application, request, **kwargs):
super(UserHandler, self).__init__(application, request, **kwargs)
self.table = 'users'
diff --git a/testapi/opnfv_testapi/resources/__init__.py b/testapi/opnfv_testapi/models/__init__.py
index 05c0c93..05c0c93 100644
--- a/testapi/opnfv_testapi/resources/__init__.py
+++ b/testapi/opnfv_testapi/models/__init__.py
diff --git a/testapi/opnfv_testapi/resources/models.py b/testapi/opnfv_testapi/models/base_models.py
index 27396d1..27396d1 100644
--- a/testapi/opnfv_testapi/resources/models.py
+++ b/testapi/opnfv_testapi/models/base_models.py
diff --git a/testapi/opnfv_testapi/resources/pod_models.py b/testapi/opnfv_testapi/models/pod_models.py
index 415d3d6..15c2833 100644
--- a/testapi/opnfv_testapi/resources/pod_models.py
+++ b/testapi/opnfv_testapi/models/pod_models.py
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@@ -17,7 +17,7 @@ from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class PodCreateRequest(models.ModelBase):
+class PodCreateRequest(base_models.ModelBase):
def __init__(self, name, mode='', details='', role=""):
self.name = name
self.mode = mode
@@ -26,7 +26,7 @@ class PodCreateRequest(models.ModelBase):
@swagger.model()
-class Pod(models.ModelBase):
+class Pod(base_models.ModelBase):
def __init__(self,
name='', mode='', details='',
role="", _id='', create_date='', owner=''):
@@ -40,7 +40,7 @@ class Pod(models.ModelBase):
@swagger.model()
-class Pods(models.ModelBase):
+class Pods(base_models.ModelBase):
"""
@property pods:
@ptype pods: C{list} of L{Pod}
diff --git a/testapi/opnfv_testapi/resources/project_models.py b/testapi/opnfv_testapi/models/project_models.py
index 3243882..5f280f1 100644
--- a/testapi/opnfv_testapi/resources/project_models.py
+++ b/testapi/opnfv_testapi/models/project_models.py
@@ -6,26 +6,26 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class ProjectCreateRequest(models.ModelBase):
+class ProjectCreateRequest(base_models.ModelBase):
def __init__(self, name, description=''):
self.name = name
self.description = description
@swagger.model()
-class ProjectUpdateRequest(models.ModelBase):
+class ProjectUpdateRequest(base_models.ModelBase):
def __init__(self, name='', description=''):
self.name = name
self.description = description
@swagger.model()
-class Project(models.ModelBase):
+class Project(base_models.ModelBase):
def __init__(self,
name=None, _id=None, description=None, create_date=None):
self._id = _id
@@ -35,7 +35,7 @@ class Project(models.ModelBase):
@swagger.model()
-class Projects(models.ModelBase):
+class Projects(base_models.ModelBase):
"""
@property projects:
@ptype projects: C{list} of L{Project}
diff --git a/testapi/opnfv_testapi/resources/result_models.py b/testapi/opnfv_testapi/models/result_models.py
index 890bf82..97fda08 100644
--- a/testapi/opnfv_testapi/resources/result_models.py
+++ b/testapi/opnfv_testapi/models/result_models.py
@@ -6,12 +6,12 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class TIHistory(models.ModelBase):
+class TIHistory(base_models.ModelBase):
"""
@ptype step: L{float}
"""
@@ -21,7 +21,7 @@ class TIHistory(models.ModelBase):
@swagger.model()
-class TI(models.ModelBase):
+class TI(base_models.ModelBase):
"""
@property histories: trust_indicator update histories
@ptype histories: C{list} of L{TIHistory}
@@ -37,7 +37,7 @@ class TI(models.ModelBase):
@swagger.model()
-class ResultCreateRequest(models.ModelBase):
+class ResultCreateRequest(base_models.ModelBase):
"""
@property trust_indicator:
@ptype trust_indicator: L{TI}
@@ -74,7 +74,7 @@ class ResultCreateRequest(models.ModelBase):
@swagger.model()
-class ResultUpdateRequest(models.ModelBase):
+class ResultUpdateRequest(base_models.ModelBase):
"""
@property trust_indicator:
@ptype trust_indicator: L{TI}
@@ -84,7 +84,7 @@ class ResultUpdateRequest(models.ModelBase):
@swagger.model()
-class TestResult(models.ModelBase):
+class TestResult(base_models.ModelBase):
"""
@property trust_indicator: used for long duration test case
@ptype trust_indicator: L{TI}
@@ -116,7 +116,7 @@ class TestResult(models.ModelBase):
@swagger.model()
-class TestResults(models.ModelBase):
+class TestResults(base_models.ModelBase):
"""
@property results:
@ptype results: C{list} of L{TestResult}
diff --git a/testapi/opnfv_testapi/resources/scenario_models.py b/testapi/opnfv_testapi/models/scenario_models.py
index d950ed1..0610c6b 100644
--- a/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/testapi/opnfv_testapi/models/scenario_models.py
@@ -1,4 +1,4 @@
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@@ -11,7 +11,7 @@ def dict_default(value):
@swagger.model()
-class ScenarioTI(models.ModelBase):
+class ScenarioTI(base_models.ModelBase):
def __init__(self, date=None, status='silver'):
self.date = date
self.status = status
@@ -25,7 +25,7 @@ class ScenarioTI(models.ModelBase):
@swagger.model()
-class ScenarioScore(models.ModelBase):
+class ScenarioScore(base_models.ModelBase):
def __init__(self, date=None, score='0'):
self.date = date
self.score = score
@@ -39,7 +39,7 @@ class ScenarioScore(models.ModelBase):
@swagger.model()
-class ScenarioProject(models.ModelBase):
+class ScenarioProject(base_models.ModelBase):
"""
@property customs:
@ptype customs: C{list} of L{string}
@@ -83,7 +83,7 @@ class ScenarioProject(models.ModelBase):
@swagger.model()
-class ScenarioVersion(models.ModelBase):
+class ScenarioVersion(base_models.ModelBase):
"""
@property projects:
@ptype projects: C{list} of L{ScenarioProject}
@@ -116,7 +116,7 @@ class ScenarioVersion(models.ModelBase):
@swagger.model()
-class ScenarioInstaller(models.ModelBase):
+class ScenarioInstaller(base_models.ModelBase):
"""
@property versions:
@ptype versions: C{list} of L{ScenarioVersion}
@@ -146,7 +146,7 @@ class ScenarioInstaller(models.ModelBase):
@swagger.model()
-class ScenarioCreateRequest(models.ModelBase):
+class ScenarioCreateRequest(base_models.ModelBase):
"""
@property installers:
@ptype installers: C{list} of L{ScenarioInstaller}
@@ -161,19 +161,19 @@ class ScenarioCreateRequest(models.ModelBase):
@swagger.model()
-class ScenarioChangeOwnerRequest(models.ModelBase):
+class ScenarioChangeOwnerRequest(base_models.ModelBase):
def __init__(self, owner=None):
self.owner = owner
@swagger.model()
-class ScenarioUpdateRequest(models.ModelBase):
+class ScenarioUpdateRequest(base_models.ModelBase):
def __init__(self, name=None):
self.name = name
@swagger.model()
-class Scenario(models.ModelBase):
+class Scenario(base_models.ModelBase):
"""
@property installers:
@ptype installers: C{list} of L{ScenarioInstaller}
@@ -205,7 +205,7 @@ class Scenario(models.ModelBase):
@swagger.model()
-class Scenarios(models.ModelBase):
+class Scenarios(base_models.ModelBase):
"""
@property scenarios:
@ptype scenarios: C{list} of L{Scenario}
diff --git a/testapi/opnfv_testapi/resources/testcase_models.py b/testapi/opnfv_testapi/models/testcase_models.py
index 2379dfc..d1b8877 100644
--- a/testapi/opnfv_testapi/resources/testcase_models.py
+++ b/testapi/opnfv_testapi/models/testcase_models.py
@@ -6,12 +6,12 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class TestcaseCreateRequest(models.ModelBase):
+class TestcaseCreateRequest(base_models.ModelBase):
def __init__(self, name, url=None, description=None,
catalog_description=None, tier=None, ci_loop=None,
criteria=None, blocking=None, dependencies=None, run=None,
@@ -33,7 +33,7 @@ class TestcaseCreateRequest(models.ModelBase):
@swagger.model()
-class TestcaseUpdateRequest(models.ModelBase):
+class TestcaseUpdateRequest(base_models.ModelBase):
def __init__(self, name=None, description=None, project_name=None,
catalog_description=None, tier=None, ci_loop=None,
criteria=None, blocking=None, dependencies=None, run=None,
@@ -55,7 +55,7 @@ class TestcaseUpdateRequest(models.ModelBase):
@swagger.model()
-class Testcase(models.ModelBase):
+class Testcase(base_models.ModelBase):
def __init__(self, _id=None, name=None, project_name=None,
description=None, url=None, creation_date=None,
catalog_description=None, tier=None, ci_loop=None,
@@ -82,7 +82,7 @@ class Testcase(models.ModelBase):
@swagger.model()
-class Testcases(models.ModelBase):
+class Testcases(base_models.ModelBase):
"""
@property testcases:
@ptype testcases: C{list} of L{Testcase}
diff --git a/testapi/opnfv_testapi/models/user_models.py b/testapi/opnfv_testapi/models/user_models.py
new file mode 100644
index 0000000..90fbadc
--- /dev/null
+++ b/testapi/opnfv_testapi/models/user_models.py
@@ -0,0 +1,9 @@
+from opnfv_testapi.models import base_models
+
+
+class User(base_models.ModelBase):
+ def __init__(self, user=None, email=None, fullname=None, groups=None):
+ self.user = user
+ self.email = email
+ self.fullname = fullname
+ self.groups = groups
diff --git a/testapi/opnfv_testapi/router/url_mappings.py b/testapi/opnfv_testapi/router/url_mappings.py
index ce0a3ee..349d557 100644
--- a/testapi/opnfv_testapi/router/url_mappings.py
+++ b/testapi/opnfv_testapi/router/url_mappings.py
@@ -9,19 +9,19 @@
import tornado.web
from opnfv_testapi.common.config import CONF
-from opnfv_testapi.resources import handlers
-from opnfv_testapi.resources import pod_handlers
-from opnfv_testapi.resources import project_handlers
-from opnfv_testapi.resources import result_handlers
-from opnfv_testapi.resources import scenario_handlers
-from opnfv_testapi.resources import testcase_handlers
-from opnfv_testapi.ui import root
-from opnfv_testapi.ui.auth import sign
-from opnfv_testapi.ui.auth import user
+from opnfv_testapi.handlers import base_handlers
+from opnfv_testapi.handlers import pod_handlers
+from opnfv_testapi.handlers import project_handlers
+from opnfv_testapi.handlers import result_handlers
+from opnfv_testapi.handlers import root_handlers
+from opnfv_testapi.handlers import scenario_handlers
+from opnfv_testapi.handlers import sign_handlers
+from opnfv_testapi.handlers import testcase_handlers
+from opnfv_testapi.handlers import user_handlers
mappings = [
# GET /versions => GET API version
- (r"/versions", handlers.VersionHandler),
+ (r"/versions", base_handlers.VersionHandler),
# few examples:
# GET /api/v1/pods => Get all pods
@@ -74,10 +74,11 @@ mappings = [
tornado.web.StaticFileHandler,
{'path': CONF.ui_static_path}),
- (r'/', root.RootHandler),
- (r'/api/v1/auth/signin', sign.SigninHandler),
- (r'/{}'.format(CONF.lfid_signin_return), sign.SigninReturnHandler),
- (r'/api/v1/auth/signout', sign.SignoutHandler),
- (r'/api/v1/profile', user.UserHandler),
+ (r'/', root_handlers.RootHandler),
+ (r'/api/v1/auth/signin', sign_handlers.SigninHandler),
+ (r'/{}'.format(CONF.lfid_signin_return),
+ sign_handlers.SigninReturnHandler),
+ (r'/api/v1/auth/signout', sign_handlers.SignoutHandler),
+ (r'/api/v1/profile', user_handlers.UserHandler),
]
diff --git a/testapi/opnfv_testapi/tests/unit/executor.py b/testapi/opnfv_testapi/tests/unit/executor.py
index aa99b90..743c076 100644
--- a/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/testapi/opnfv_testapi/tests/unit/executor.py
@@ -14,7 +14,7 @@ import mock
O_get_secure_cookie = (
- 'opnfv_testapi.resources.handlers.GenericApiHandler.get_secure_cookie')
+ 'opnfv_testapi.handlers.base_handlers.GenericApiHandler.get_secure_cookie')
def thread_execute(method, *args, **kwargs):
diff --git a/testapi/opnfv_testapi/ui/__init__.py b/testapi/opnfv_testapi/tests/unit/handlers/__init__.py
index e69de29..e69de29 100644
--- a/testapi/opnfv_testapi/ui/__init__.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/__init__.py
diff --git a/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json b/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json
index 1878022..1878022 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json
+++ b/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json
diff --git a/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json b/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json
index 980051c..980051c 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
+++ b/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_base.py b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
index 89cd7e8..b7fabb9 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_base.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
@@ -14,8 +14,8 @@ from bson.objectid import ObjectId
import mock
from tornado import testing
-from opnfv_testapi.resources import models
-from opnfv_testapi.resources import pod_models
+from opnfv_testapi.models import base_models
+from opnfv_testapi.models import pod_models
from opnfv_testapi.tests.unit import fake_pymongo
@@ -25,7 +25,7 @@ class TestBase(testing.AsyncHTTPTestCase):
def setUp(self):
self._patch_server()
self.basePath = ''
- self.create_res = models.CreateResponse
+ self.create_res = base_models.CreateResponse
self.get_res = None
self.list_res = None
self.update_res = None
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_pod.py b/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
index 5d9da3a..95ed8ba 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_pod.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
@@ -10,10 +10,10 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import pod_models
+from opnfv_testapi.models import pod_models
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestPodBase(base.TestBase):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_project.py b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
index 0622ba8..939cc0d 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_project.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
@@ -2,9 +2,9 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
+from opnfv_testapi.models import project_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestProjectBase(base.TestBase):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_result.py b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
index 6c1a07a..b9f9ede 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_result.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
@@ -15,12 +15,12 @@ import urllib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
-from opnfv_testapi.resources import result_models
-from opnfv_testapi.resources import testcase_models
+from opnfv_testapi.models import project_models
+from opnfv_testapi.models import result_models
+from opnfv_testapi.models import testcase_models
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class Details(object):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
index 1367fc6..de7777a 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
@@ -6,8 +6,8 @@ import os
from datetime import datetime
from opnfv_testapi.common import message
-import opnfv_testapi.resources.scenario_models as models
-from opnfv_testapi.tests.unit.resources import test_base as base
+import opnfv_testapi.models.scenario_models as models
+from opnfv_testapi.tests.unit.handlers import test_base as base
def _none_default(check, default):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py b/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
index 4f2bc2a..e4c668e 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
@@ -11,10 +11,10 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
-from opnfv_testapi.resources import testcase_models
+from opnfv_testapi.models import project_models
+from opnfv_testapi.models import testcase_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestCaseBase(base.TestBase):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_token.py b/testapi/opnfv_testapi/tests/unit/handlers/test_token.py
index bd64723..e8b746d 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_token.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_token.py
@@ -11,7 +11,7 @@ from tornado import web
from opnfv_testapi.common import message
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_result
+from opnfv_testapi.tests.unit.handlers import test_result
class TestTokenCreateResult(test_result.TestResultBase):
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_version.py b/testapi/opnfv_testapi/tests/unit/handlers/test_version.py
index 51fed11..6ef810f 100644
--- a/testapi/opnfv_testapi/tests/unit/resources/test_version.py
+++ b/testapi/opnfv_testapi/tests/unit/handlers/test_version.py
@@ -9,15 +9,15 @@
import httplib
import unittest
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestVersionBase(base.TestBase):
def setUp(self):
super(TestVersionBase, self).setUp()
- self.list_res = models.Versions
+ self.list_res = base_models.Versions
self.basePath = '/versions'
diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
deleted file mode 100644
index 1ebc96f..0000000
--- a/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
+++ /dev/null
@@ -1,123 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-import unittest
-
-from tornado import gen
-from tornado import testing
-from tornado import web
-
-from opnfv_testapi.tests.unit import fake_pymongo
-
-
-class MyTest(testing.AsyncHTTPTestCase):
- def setUp(self):
- super(MyTest, self).setUp()
- self.db = fake_pymongo
- self.addCleanup(self._clear)
- self.io_loop.run_sync(self.fixture_setup)
-
- def get_app(self):
- return web.Application()
-
- @gen.coroutine
- def fixture_setup(self):
- self.test1 = {'_id': '1', 'name': 'test1'}
- self.test2 = {'name': 'test2'}
- yield self.db.pods.insert({'_id': '1', 'name': 'test1'})
- yield self.db.pods.insert({'name': 'test2'})
-
- @testing.gen_test
- def test_find_one(self):
- user = yield self.db.pods.find_one({'name': 'test1'})
- self.assertEqual(user, self.test1)
- self.db.pods.remove()
-
- @testing.gen_test
- def test_find(self):
- cursor = self.db.pods.find()
- names = []
- while (yield cursor.fetch_next):
- ob = cursor.next_object()
- names.append(ob.get('name'))
- self.assertItemsEqual(names, ['test1', 'test2'])
-
- @testing.gen_test
- def test_update(self):
- yield self.db.pods.update({'_id': '1'}, {'name': 'new_test1'})
- user = yield self.db.pods.find_one({'_id': '1'})
- self.assertEqual(user.get('name', None), 'new_test1')
-
- def test_update_dot_error(self):
- self._update_assert({'_id': '1', 'name': {'1. name': 'test1'}},
- 'key 1. name must not contain .')
-
- def test_update_dot_no_error(self):
- self._update_assert({'_id': '1', 'name': {'1. name': 'test1'}},
- None,
- check_keys=False)
-
- def test_update_dollar_error(self):
- self._update_assert({'_id': '1', 'name': {'$name': 'test1'}},
- 'key $name must not start with $')
-
- def test_update_dollar_no_error(self):
- self._update_assert({'_id': '1', 'name': {'$name': 'test1'}},
- None,
- check_keys=False)
-
- @testing.gen_test
- def test_remove(self):
- yield self.db.pods.remove({'_id': '1'})
- user = yield self.db.pods.find_one({'_id': '1'})
- self.assertIsNone(user)
-
- def test_insert_dot_error(self):
- self._insert_assert({'_id': '1', '2. name': 'test1'},
- 'key 2. name must not contain .')
-
- def test_insert_dot_no_error(self):
- self._insert_assert({'_id': '1', '2. name': 'test1'},
- None,
- check_keys=False)
-
- def test_insert_dollar_error(self):
- self._insert_assert({'_id': '1', '$name': 'test1'},
- 'key $name must not start with $')
-
- def test_insert_dollar_no_error(self):
- self._insert_assert({'_id': '1', '$name': 'test1'},
- None,
- check_keys=False)
-
- def _clear(self):
- self.db.pods.clear()
-
- def _update_assert(self, docs, error=None, **kwargs):
- self._db_assert('update', error, {'_id': '1'}, docs, **kwargs)
-
- def _insert_assert(self, docs, error=None, **kwargs):
- self._db_assert('insert', error, docs, **kwargs)
-
- @testing.gen_test
- def _db_assert(self, method, error, *args, **kwargs):
- name_error = None
- try:
- yield self._eval_pods_db(method, *args, **kwargs)
- except NameError as err:
- name_error = err.args[0]
- finally:
- self.assertEqual(name_error, error)
-
- def _eval_pods_db(self, method, *args, **kwargs):
- table_obj = vars(self.db)['pods']
- return table_obj.__getattribute__(method)(*args, **kwargs)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/testapi/opnfv_testapi/tornado_swagger/handlers.py b/testapi/opnfv_testapi/tornado_swagger/handlers.py
index e39a9f6..a04de07 100644
--- a/testapi/opnfv_testapi/tornado_swagger/handlers.py
+++ b/testapi/opnfv_testapi/tornado_swagger/handlers.py
@@ -26,7 +26,7 @@ def swagger_handlers():
settings.docs_settings,
name=settings.API_DOCS_NAME),
tornado.web.URLSpec(
- _path(r'resources.json$'),
+ _path(r'models.json$'),
views.SwaggerResourcesHandler,
settings.docs_settings,
name=settings.RESOURCE_LISTING_NAME),
diff --git a/testapi/opnfv_testapi/ui/auth/__init__.py b/testapi/opnfv_testapi/ui/auth/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testapi/opnfv_testapi/ui/auth/__init__.py
+++ /dev/null