Add test environment
At now, there is no build check for the repository. Having some build check would be nice. Change-Id: Ie22c5adf67da4fc5d805569b4a53752a25fae5f3
This commit is contained in:
parent
6e9c342e91
commit
cfe08218dc
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
cookiecutter
|
1
test-requirements.txt
Normal file
1
test-requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
24
tox.ini
Normal file
24
tox.ini
Normal file
@ -0,0 +1,24 @@
|
||||
[tox]
|
||||
minversion = 2.0
|
||||
envlist = checkbuild
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
basepython = python2.7
|
||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U {opts} {packages}
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
deps =
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:checkbuild]
|
||||
commands =
|
||||
rm -rf {envdir}/cafe-ui
|
||||
cookiecutter --no-input --output-dir {envdir} {toxinidir}
|
||||
flake8 {envdir}/cafe-ui
|
||||
whitelist_externals =
|
||||
rm
|
@ -209,8 +209,11 @@ latex_elements = {
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', '{{cookiecutter.help_name }}ReleaseNotes.tex', u'{{cookiecutter.call_by_name }} Release Notes Documentation',
|
||||
u'{{cookiecutter.call_by_name }} Developers', 'manual'),
|
||||
('index',
|
||||
'{{cookiecutter.help_name }}ReleaseNotes.tex',
|
||||
u'{{cookiecutter.call_by_name }} Release Notes Documentation',
|
||||
u'{{cookiecutter.call_by_name }} Developers',
|
||||
'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -12,8 +12,10 @@
|
||||
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
#from {{cookiecutter.api_module}}client.v1 import client as {{cookiecutter.api_module}}_client
|
||||
|
||||
from {{cookiecutter.api_module}}client.v1 import client as {{cookiecutter.api_module}}_client
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.utils.memoized import memoized
|
||||
@ -28,10 +30,11 @@ import uuid
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
ATTRIBUTES = ['name', 'description', 'enabled', 'size', 'temperature',
|
||||
'base', 'flavor', 'topping']
|
||||
'base', 'flavor', 'topping']
|
||||
|
||||
STUB_DATA = {}
|
||||
|
||||
|
||||
# for stab, should be removed when use CLI API
|
||||
class StubResponse(object):
|
||||
|
||||
@ -50,7 +53,7 @@ class StubResponse(object):
|
||||
@memoized
|
||||
def apiclient(request):
|
||||
api_url = ""
|
||||
""""
|
||||
|
||||
try:
|
||||
api_url = base.url_for(request, '{{cookiecutter.panel}}')
|
||||
except exceptions.ServiceCatalogException:
|
||||
@ -59,12 +62,12 @@ def apiclient(request):
|
||||
|
||||
LOG.debug('{{cookiecutter.api_module}}client connection created using the token "%s" and url'
|
||||
'"%s"' % (request.user.token.id, api_url))
|
||||
c = {{cookiecutter.api_module}}_client.Client(username=request.user.username,
|
||||
project_id=request.user.tenant_id,
|
||||
input_auth_token=request.user.token.id,
|
||||
api_url=api_url)
|
||||
c = {{cookiecutter.api_module}}_client.Client(
|
||||
username=request.user.username,
|
||||
project_id=request.user.tenant_id,
|
||||
input_auth_token=request.user.token.id,
|
||||
api_url=api_url)
|
||||
return c
|
||||
"""
|
||||
|
||||
|
||||
def {{cookiecutter.panel}}_create(request, **kwargs):
|
||||
@ -75,7 +78,7 @@ def {{cookiecutter.panel}}_create(request, **kwargs):
|
||||
else:
|
||||
raise exceptions.BadRequest(
|
||||
"Key must be in %s" % ",".join(ATTRIBUTES))
|
||||
#created = apiclient(request).{{cookiecutter.panel}}s.create(**args)
|
||||
# created = apiclient(request).{{cookiecutter.panel}}s.create(**args)
|
||||
|
||||
# create dummy response
|
||||
args["uuid"] = uuid.uuid1().hex
|
||||
@ -96,7 +99,7 @@ def {{cookiecutter.panel}}_update(request, id, **kwargs):
|
||||
else:
|
||||
raise exceptions.BadRequest(
|
||||
"Key must be in %s" % ",".join(ATTRIBUTES))
|
||||
#updated = apiclient(request).{{cookiecutter.panel}}.update(id, **args)
|
||||
# updated = apiclient(request).{{cookiecutter.panel}}.update(id, **args)
|
||||
|
||||
# update dummy response
|
||||
args["uuid"] = id
|
||||
@ -110,21 +113,23 @@ def {{cookiecutter.panel}}_update(request, id, **kwargs):
|
||||
|
||||
|
||||
def {{cookiecutter.panel}}_delete(request, id):
|
||||
#deleted = apiclient(request).{{cookiecutter.panel}}s.delete(id)
|
||||
# deleted = apiclient(request).{{cookiecutter.panel}}s.delete(id)
|
||||
deleted = STUB_DATA.pop(id)
|
||||
|
||||
return deleted
|
||||
|
||||
|
||||
def {{cookiecutter.panel}}_list(request, limit=None, marker=None, sort_key=None,
|
||||
sort_dir=None, detail=True):
|
||||
#list = apiclient(request).{{cookiecutter.panel_func}}s.list(limit, marker, sort_key,
|
||||
# sort_dir, detail)
|
||||
def {{cookiecutter.panel}}_list(
|
||||
request, limit=None, marker=None, sort_key=None,
|
||||
sort_dir=None, detail=True):
|
||||
|
||||
# list = apiclient(request).{{cookiecutter.panel_func}}s.list(limit, marker, sort_key,
|
||||
# sort_dir, detail)
|
||||
list = [STUB_DATA[data] for data in STUB_DATA]
|
||||
return list
|
||||
|
||||
|
||||
def {{cookiecutter.panel}}_show(request, id):
|
||||
#show = apiclient(request).{{cookiecutter.panel}}s.get(id)
|
||||
# show = apiclient(request).{{cookiecutter.panel}}s.get(id)
|
||||
show = STUB_DATA.get(id)
|
||||
return show
|
||||
|
@ -17,6 +17,7 @@ import horizon
|
||||
# To register REST api, import below here.
|
||||
from {{cookiecutter.module_folder}}.api import rest_api # noqa
|
||||
|
||||
|
||||
class {{cookiecutter.panel_func}}s(horizon.Panel):
|
||||
name = _("{{cookiecutter.panel_func}}s")
|
||||
slug = "{{cookiecutter.panel}}s"
|
||||
|
@ -18,4 +18,3 @@ title = _("{{cookiecutter.panel_func}}s")
|
||||
urlpatterns = [
|
||||
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user