Add a gitreview and modify for unit-testing

Change-Id: Ib2eb728e092383a81fb2d888842fd2e1b1d7fbe7
This commit is contained in:
Hiroyuki Eguchi 2017-02-01 14:35:05 +09:00
parent 94b9cf4820
commit 40cb671811
7 changed files with 37 additions and 24 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.pyc

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/meteos-ui.git

View File

@ -14,8 +14,8 @@
from horizon import exceptions from horizon import exceptions
from horizon.utils.memoized import memoized from horizon.utils.memoized import memoized
import logging import logging
from openstack_dashboard.api import base
from meteosclient.api import client as meteos_client from meteosclient.api import client as meteos_client
from openstack_dashboard.api import base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -52,9 +52,9 @@ def meteosclient(request):
LOG.debug('meteosclient connection created using the token "%s" and url' LOG.debug('meteosclient connection created using the token "%s" and url'
'"%s"' % (request.user.token.id, meteos_url)) '"%s"' % (request.user.token.id, meteos_url))
c = meteos_client.Client(username=request.user.username, c = meteos_client.Client(username=request.user.username,
project_id=request.user.tenant_id, project_id=request.user.tenant_id,
input_auth_token=request.user.token.id, input_auth_token=request.user.token.id,
meteos_url=meteos_url) meteos_url=meteos_url)
return c return c
@ -130,12 +130,12 @@ def dataset_delete(request, id):
def dataset_list(request, search_opts=None, limit=None, marker=None, def dataset_list(request, search_opts=None, limit=None, marker=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
return meteosclient(request).datasets.list(search_opts, return meteosclient(request).datasets.list(search_opts,
limit, limit,
marker, marker,
sort_key, sort_key,
sort_dir) sort_dir)
def dataset_show(request, id): def dataset_show(request, id):
@ -158,7 +158,7 @@ def model_delete(request, id):
def model_list(request, search_opts=None, limit=None, marker=None, def model_list(request, search_opts=None, limit=None, marker=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
return meteosclient(request).models.list(search_opts, return meteosclient(request).models.list(search_opts,
limit, limit,
marker, marker,
@ -186,7 +186,7 @@ def model_evaluation_delete(request, id):
def model_evaluation_list(request, search_opts=None, limit=None, marker=None, def model_evaluation_list(request, search_opts=None, limit=None, marker=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
return meteosclient(request).model_evaluations.list(search_opts, return meteosclient(request).model_evaluations.list(search_opts,
limit, limit,
marker, marker,
@ -214,12 +214,12 @@ def learning_delete(request, id):
def learning_list(request, search_opts=None, limit=None, marker=None, def learning_list(request, search_opts=None, limit=None, marker=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
return meteosclient(request).learnings.list(search_opts, return meteosclient(request).learnings.list(search_opts,
limit, limit,
marker, marker,
sort_key, sort_key,
sort_dir) sort_dir)
def learning_show(request, id): def learning_show(request, id):

View File

@ -26,7 +26,7 @@ class Template(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific template""" """Get a specific template"""
return change_to_id(client.template_show(request, id).to_dict()) return client.template_show(request, id).to_dict()
@urls.register @urls.register
@ -79,7 +79,7 @@ class Experiment(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific experiment""" """Get a specific experiment"""
return change_to_id(client.experiment_show(request, id).to_dict()) return client.experiment_show(request, id).to_dict()
@urls.register @urls.register
@ -132,7 +132,7 @@ class Dataset(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific dataset""" """Get a specific dataset"""
return change_to_id(client.dataset_show(request, id).to_dict()) return client.dataset_show(request, id).to_dict()
@urls.register @urls.register
@ -185,7 +185,7 @@ class Model(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific model""" """Get a specific model"""
return change_to_id(client.model_show(request, id).to_dict()) return client.model_show(request, id).to_dict()
@urls.register @urls.register
@ -238,7 +238,7 @@ class ModelEvaluation(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific model_evaluation""" """Get a specific model_evaluation"""
return change_to_id(client.model_evaluation_show(request, id).to_dict()) return client.model_evaluation_show(request, id).to_dict()
@urls.register @urls.register
@ -292,7 +292,7 @@ class Learning(generic.View):
@rest_utils.ajax() @rest_utils.ajax()
def get(self, request, id): def get(self, request, id):
"""Get a specific learning""" """Get a specific learning"""
return change_to_id(client.learning_show(request, id).to_dict()) return client.learning_show(request, id).to_dict()
@urls.register @urls.register

View File

@ -18,4 +18,5 @@ PANEL_GROUP = 'machine_learning'
PANEL_DASHBOARD = 'project' PANEL_DASHBOARD = 'project'
# Python panel class of the PANEL to be added. # Python panel class of the PANEL to be added.
ADD_PANEL = 'meteos_ui.content.machine_learning.model_evaluations.panel.ModelEvaluations' ADD_PANEL = 'meteos_ui.content.machine_learning.model_evaluations.panel.\
ModelEvaluations'

View File

@ -22,6 +22,7 @@ HORIZON_CONFIG.pop('default_dashboard', None)
# Update the dashboards with meteos_ui # Update the dashboards with meteos_ui
import openstack_dashboard.enabled import openstack_dashboard.enabled
from openstack_dashboard.utils import settings from openstack_dashboard.utils import settings
import meteos_ui.enabled import meteos_ui.enabled
settings.update_dashboards( settings.update_dashboards(

View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py34,py27,py27dj18,pep8 envlist = py35,py34,py27,py27dj18,pep8
minversion = 2.0 minversion = 2.0
skipsdist = True skipsdist = True
@ -18,6 +18,12 @@ deps = -r{toxinidir}/requirements.txt
commands = python manage.py test {posargs} --settings=meteos_ui.test.settings commands = python manage.py test {posargs} --settings=meteos_ui.test.settings
# Until python-meteosclient released, install from github temporary. # Until python-meteosclient released, install from github temporary.
[testenv:py35]
basepython = python3.5
commands =
pip install git+https://github.com/openstack/python-meteosclient.git
python manage.py test {posargs} --settings=meteos_ui.test.settings
[testenv:py27] [testenv:py27]
basepython = python2.7 basepython = python2.7
commands = commands =