*.egg-info
3rd_party/static/static
*.pyc
+.cache
+.eggs
+.tox
+.ven
+docs/_build
--- /dev/null
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+SPHINXPROJ = OPNFVTestAPI
+SOURCEDIR = .
+BUILDDIR = _build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# OPNFV TestAPI documentation build configuration file, created by
+# sphinx-quickstart on Thu Oct 26 10:23:57 2017.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#
+# needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+#
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'OPNFV TestAPI'
+copyright = u'2017, SerenaFeng'
+author = u'SerenaFeng'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = u'v1.0'
+# The full version, including alpha/beta/rc tags.
+release = u'v1.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This patterns also effect to html_static_path and html_extra_path
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#
+html_theme = 'alabaster'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#
+# html_theme_options = {}
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+# html_static_path = ['_static']
+
+# Custom sidebar templates, must be a dictionary that maps document names
+# to template names.
+#
+# This is required for the alabaster theme
+# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
+html_sidebars = {
+ '**': [
+ 'relations.html', # needs 'show_related': True theme option to display
+ 'searchbox.html',
+ ]
+}
+
+
+# -- Options for HTMLHelp output ------------------------------------------
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'OPNFVTestAPIdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+ # The paper size ('letterpaper' or 'a4paper').
+ #
+ # 'papersize': 'letterpaper',
+
+ # The font size ('10pt', '11pt' or '12pt').
+ #
+ # 'pointsize': '10pt',
+
+ # Additional stuff for the LaTeX preamble.
+ #
+ # 'preamble': '',
+
+ # Latex figure (float) alignment
+ #
+ # 'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ (master_doc, 'OPNFVTestAPI.tex', u'OPNFV TestAPI Documentation',
+ u'SerenaFeng', 'manual'),
+]
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ (master_doc, 'opnfvtestapi', u'OPNFV TestAPI Documentation',
+ [author], 1)
+]
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ (master_doc, 'OPNFVTestAPI', u'OPNFV TestAPI Documentation',
+ author, 'OPNFVTestAPI', 'One line description of project.',
+ 'Miscellaneous'),
+]
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+============
+Restful APIs
+============
+
+.. toctree::
+ :maxdepth: 2
-=============
-opnfv-testapi
-=============
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+
+.. toctree::
+ :maxdepth: 2
+
+=========
+Framework
+=========
**Test Results Collector of OPNFV Test Projects**:
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+
+***********************
+TestAPI Developer Guide
+***********************
+
+.. toctree::
+ :maxdepth: 2
+
+ overview.rst
+ framework.rst
+ api.rst
+ swagger-ui.rst
+ web-portal.rst
+ testapi-client.rst
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corporation
+
+
+********
+Overview
+********
+
+TestAPI uses Python as primary programming language and build the framework from the following packages
+
+======== ===============================================================================================================
+Module Package
+======== ===============================================================================================================
+api `Tornado-Motor`_ - API applications using Motor with tornado
+swagger `tornado-swagger`_ - a wrapper for tornado which enables swagger-ui-v1.2 support
+web `angular`_ - a superheroic JavaScript MVW framework, the version is AngularJS v1.3.15
+docs `sphinx`_ - a tool that makes it easy to create intelligent and beautiful documentation
+testing `pytest`_ - a mature full-featured Python testing tool that helps you write better programs
+======== ===============================================================================================================
+
+
+Source Code
+===========
+
+The structure of repository is based on the recommended sample in `The Hitchhiker's Guide to Python`_
+
+========================== ====================================================================================================
+Path Content
+========================== ====================================================================================================
+``./3rd_party/`` third part included in TestAPI project
+``./docker/`` configuration for building Docker image for TestAPI deployment
+``./docs/`` user and developer documentation, design proposals
+``./etc/`` configuration files used to install opnfv-testapi
+``./opnfv_testapi/`` the actual package
+``./opnfv_testapi/tests/`` package functional and unit tests
+``./opts/`` optional components, e.g. one click deployment script
+========================== ====================================================================================================
+
+
+Coding Style
+============
+
+TestAPI follows `OpenStack Style Guidelines`_ for source code and commit message.
+
+Specially, it is recommended to link each patch set with a JIRA issue. Put::
+
+ JIRA: RELENG-n
+
+in commit message to create an automatic link.
+
+
+Testing
+=======
+
+All testing related code are stored in ``./opnfv_testapi/tests/``
+
+================== ====================================================================================================
+Path Content
+================== ====================================================================================================
+``./tests/unit/`` unit test for each module, follow the same layout as ./opnfv_testapi/
+``./conftest.py`` pytest configuration in project scope
+================== ====================================================================================================
+
+`tox`_ is used to automate the testing tasks
+
+.. code-block:: shell
+
+ cd <project_root>
+ pip install tox
+ tox
+
+The test cases are written in `pytest`_. You may run it selectively with
+
+.. code-block:: shell
+
+ pytest opnfv_testapi/tests/unit/common/test_config.py
+
+
+Branching
+=========
+
+Currently, no branching for TestAPI, only master branch
+
+
+Releasing
+=========
+
+Currently, TestAPI does not follow community's milestones and releases
+
+.. _Tornado-Motor: https://motor.readthedocs.io/en/stable/tutorial-tornado.html
+.. _tornado-swagger: https://github.com/SerenaFeng/tornado-swagger
+.. _angular: https://code.angularjs.org/1.3.15/docs/guide
+.. _sphinx: http://www.sphinx-doc.org/en/stable/
+.. _pytest: http://doc.pytest.org/
+.. _OpenStack Style Guidelines: http://docs.openstack.org/developer/hacking/
+.. _The Hitchhiker's Guide to Python: http://python-guide-pt-br.readthedocs.io/en/latest/writing/structure/
+.. _tox: https://tox.readthedocs.io/
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+============
+Swagger page
+============
+
+.. toctree::
+ :maxdepth: 2
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+==============
+TestAPI client
+==============
+
+.. toctree::
+ :maxdepth: 2
--- /dev/null
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. (c) 2017 ZTE Corp.
+
+==========
+Web portal
+==========
+
+.. toctree::
+ :maxdepth: 2
--- /dev/null
+.. OPNFV TestAPI documentation master file, created by
+ sphinx-quickstart on Thu Oct 26 10:23:57 2017.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to OPNFV TestAPI's documentation!
+=========================================
+
+.. toctree::
+ :maxdepth: 2
+ :caption: Contents:
+
+
+Developer Guide
+===============
+
+.. toctree::
+ :maxdepth: 2
+
+ developer/devguide/index.rst
# 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
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"
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)
# 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'
# 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,
# 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,
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
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,
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'
# 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,
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'
# 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 PodCreateRequest(models.ModelBase):
+class PodCreateRequest(base_models.ModelBase):
def __init__(self, name, mode='', details='', role=""):
self.name = name
self.mode = mode
@swagger.model()
-class Pod(models.ModelBase):
+class Pod(base_models.ModelBase):
def __init__(self,
name='', mode='', details='',
role="", _id='', create_date='', owner=''):
@swagger.model()
-class Pods(models.ModelBase):
+class Pods(base_models.ModelBase):
"""
@property pods:
@ptype pods: C{list} of L{Pod}
# 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
@swagger.model()
-class Projects(models.ModelBase):
+class Projects(base_models.ModelBase):
"""
@property projects:
@ptype projects: C{list} of L{Project}
# 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}
"""
@swagger.model()
-class TI(models.ModelBase):
+class TI(base_models.ModelBase):
"""
@property histories: trust_indicator update histories
@ptype histories: C{list} of L{TIHistory}
@swagger.model()
-class ResultCreateRequest(models.ModelBase):
+class ResultCreateRequest(base_models.ModelBase):
"""
@property trust_indicator:
@ptype trust_indicator: L{TI}
@swagger.model()
-class ResultUpdateRequest(models.ModelBase):
+class ResultUpdateRequest(base_models.ModelBase):
"""
@property trust_indicator:
@ptype trust_indicator: L{TI}
@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}
@swagger.model()
-class TestResults(models.ModelBase):
+class TestResults(base_models.ModelBase):
"""
@property results:
@ptype results: C{list} of L{TestResult}
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tornado_swagger import swagger
@swagger.model()
-class ScenarioTI(models.ModelBase):
+class ScenarioTI(base_models.ModelBase):
def __init__(self, date=None, status='silver'):
self.date = date
self.status = status
@swagger.model()
-class ScenarioScore(models.ModelBase):
+class ScenarioScore(base_models.ModelBase):
def __init__(self, date=None, score='0'):
self.date = date
self.score = score
@swagger.model()
-class ScenarioProject(models.ModelBase):
+class ScenarioProject(base_models.ModelBase):
"""
@property customs:
@ptype customs: C{list} of L{string}
@swagger.model()
-class ScenarioVersion(models.ModelBase):
+class ScenarioVersion(base_models.ModelBase):
"""
@property projects:
@ptype projects: C{list} of L{ScenarioProject}
@swagger.model()
-class ScenarioInstaller(models.ModelBase):
+class ScenarioInstaller(base_models.ModelBase):
"""
@property versions:
@ptype versions: C{list} of L{ScenarioVersion}
@swagger.model()
-class ScenarioCreateRequest(models.ModelBase):
+class ScenarioCreateRequest(base_models.ModelBase):
"""
@property installers:
@ptype installers: C{list} of L{ScenarioInstaller}
@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}
@swagger.model()
-class Scenarios(models.ModelBase):
+class Scenarios(base_models.ModelBase):
"""
@property scenarios:
@ptype scenarios: C{list} of L{Scenario}
# 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,
@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,
@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,
@swagger.model()
-class Testcases(models.ModelBase):
+class Testcases(base_models.ModelBase):
"""
@property testcases:
@ptype testcases: C{list} of L{Testcase}
--- /dev/null
+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
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
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),
]
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):
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
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
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):
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):
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):
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):
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):
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):
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'
+++ /dev/null
-##############################################################################
-# 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()
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),
[metadata]
name = opnfv_testapi
summary = Test Result Collector
-description-file =
- README.rst
author = SerenaFeng
author-email = feng.xiaowei@zte.com.cn
#home-page = http://www.opnfv.org/
data_files =
/etc/opnfv_testapi = etc/config.ini
/usr/local/share/opnfv_testapi = 3rd_party/static/*
+ /usr/local/share/opnfv_testapi/testapi-ui/components = opnfv_testapi/ui/*
[entry_points]
console_scripts =
HOME = {envtmpdir}
PYTHONPATH = {toxinidir}
+[testenv:docs]
+basepython=python2.7
+commands = sphinx-build -W -b html docs/ docs/_build
+
[testenv:pep8]
deps = flake8
commands = flake8 {toxinidir}