Setup python test environment
This patch adds python test environment and test skeleton. Also need to set sphinx output to make the docs job pass at the same time. Change-Id: Icf5f2a210b7b02e90eb98dc285223ba4f7377a66 Closes-Bug: #1608412
This commit is contained in:
parent
6ed5bfc0eb
commit
19bca99ccf
@ -22,3 +22,9 @@ classifier =
|
|||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
zaqar_ui
|
zaqar_ui
|
||||||
|
|
||||||
|
[build_sphinx]
|
||||||
|
all_files = 1
|
||||||
|
build-dir = doc/build
|
||||||
|
source-dir = doc/source
|
||||||
|
|
||||||
|
30
tox.ini
30
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py27,py27dj18,pep834
|
envlist = py27,py27dj18,pep8,py34
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
@ -11,42 +11,28 @@ setenv = VIRTUAL_ENV={envdir}
|
|||||||
NOSE_OPENSTACK_RED=0.05
|
NOSE_OPENSTACK_RED=0.05
|
||||||
NOSE_OPENSTACK_YELLOW=0.025
|
NOSE_OPENSTACK_YELLOW=0.025
|
||||||
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
NOSE_OPENSTACK_SHOW_ELAPSED=1
|
||||||
# Note the hash seed is set to 0 until horizon can be tested with a
|
DJANGO_SETTINGS_MODULE=zaqar_ui.test.settings
|
||||||
# random hash seed successfully.
|
|
||||||
PYTHONHASHSEED=0
|
|
||||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U {opts} {packages}
|
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -U {opts} {packages}
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = /bin/bash run_tests.sh -N --no-pep8 {posargs}
|
commands = python manage.py test {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands =
|
commands = flake8 {posargs}
|
||||||
/bin/bash run_tests.sh -N --pep8
|
|
||||||
/bin/bash run_tests.sh -N --makemessages --check-only
|
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands = /bin/bash run_tests.sh -N --no-pep8 --coverage {posargs}
|
commands = python setup.py test --coverage --testr-args='{posargs}'
|
||||||
|
|
||||||
[testenv:py27dj18]
|
[testenv:py27dj18]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
commands = pip install django>=1.8,<1.9
|
commands =
|
||||||
/bin/bash run_tests.sh -N --no-pep8 {posargs}
|
pip install django>=1.8,<1.9
|
||||||
|
python manage.py test {posargs}
|
||||||
[testenv:py27integration]
|
|
||||||
basepython = python2.7
|
|
||||||
commands = /bin/bash run_tests.sh -N --integration --selenium-headless {posargs}
|
|
||||||
|
|
||||||
[testenv:eslint]
|
|
||||||
passenv = *
|
|
||||||
commands = nodeenv -p
|
|
||||||
npm install
|
|
||||||
/bin/bash run_tests.sh -N --eslint
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
setenv = DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
|
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
|
0
zaqar_ui/enabled/__init__.py
Normal file
0
zaqar_ui/enabled/__init__.py
Normal file
0
zaqar_ui/test/__init__.py
Normal file
0
zaqar_ui/test/__init__.py
Normal file
0
zaqar_ui/test/api_tests/__init__.py
Normal file
0
zaqar_ui/test/api_tests/__init__.py
Normal file
48
zaqar_ui/test/api_tests/rest_api_tests.py
Normal file
48
zaqar_ui/test/api_tests/rest_api_tests.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from openstack_dashboard.test import helpers as test
|
||||||
|
from openstack_dashboard.test.test_data.utils import TestData
|
||||||
|
from zaqar_ui.api.rest import zaqar
|
||||||
|
from zaqar_ui.test import test_data
|
||||||
|
|
||||||
|
TEST = TestData(test_data.data)
|
||||||
|
|
||||||
|
|
||||||
|
class ZaqarRestTestCase(test.TestCase):
|
||||||
|
|
||||||
|
# Queues
|
||||||
|
@mock.patch.object(zaqar, 'zaqar')
|
||||||
|
def test_queue_get(self, client):
|
||||||
|
# for check test env
|
||||||
|
self.assertTrue(1 * 1 == 1)
|
||||||
|
|
||||||
|
@mock.patch.object(zaqar, 'zaqar')
|
||||||
|
def test_queue_create(self, client):
|
||||||
|
# for check test env
|
||||||
|
self.assertTrue(1 + 1 == 2)
|
||||||
|
|
||||||
|
@mock.patch.object(zaqar, 'zaqar')
|
||||||
|
def test_queue_delete(self, client):
|
||||||
|
# for check test env
|
||||||
|
self.assertTrue(1 - 1 == 0)
|
||||||
|
|
||||||
|
|
||||||
|
def mock_resource(resource):
|
||||||
|
"""Utility function to make mocking more DRY"""
|
||||||
|
|
||||||
|
mocked_data = \
|
||||||
|
[mock.Mock(**{'to_dict.return_value': item}) for item in resource]
|
||||||
|
|
||||||
|
return mocked_data
|
39
zaqar_ui/test/helpers.py
Normal file
39
zaqar_ui/test/helpers.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from openstack_dashboard.test import helpers
|
||||||
|
from zaqar_ui import api
|
||||||
|
from zaqar_ui.test import test_data
|
||||||
|
from zaqarclient.queues.v2 import client as zaqar_client
|
||||||
|
|
||||||
|
|
||||||
|
class APITestCase(helpers.APITestCase):
|
||||||
|
"""Extends the base Horizon APITestCase for zaqarclient"""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(APITestCase, self).setUp()
|
||||||
|
self._original_magnumclient = api.zaqar.zaqarclient
|
||||||
|
api.zaqar.zaqarclient = lambda request: self.stub_zaqarclient()
|
||||||
|
|
||||||
|
def _setup_test_data(self):
|
||||||
|
super(APITestCase, self)._setup_test_data()
|
||||||
|
test_data.data(self)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(APITestCase, self).tearDown()
|
||||||
|
api.zaqar.zaqarclient = self._original_zaqarclient
|
||||||
|
|
||||||
|
def stub_zaqarclient(self):
|
||||||
|
if not hasattr(self, "zaqarclient"):
|
||||||
|
self.mox.StubOutWithMock(zaqar_client, 'Client')
|
||||||
|
self.zaqarclient = self.mox.CreateMock(zaqar_client.Client)
|
||||||
|
return self.zaqarclient
|
0
zaqar_ui/test/integration_tests/__init__.py
Normal file
0
zaqar_ui/test/integration_tests/__init__.py
Normal file
37
zaqar_ui/test/settings.py
Normal file
37
zaqar_ui/test/settings.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
# Default to Horizons test settings to avoid any missing keys
|
||||||
|
from horizon.test.settings import * # noqa
|
||||||
|
from openstack_dashboard.test.settings import * # noqa
|
||||||
|
|
||||||
|
# pop these keys to avoid log warnings about deprecation
|
||||||
|
# update_dashboards will populate them anyway
|
||||||
|
HORIZON_CONFIG.pop('dashboards', None)
|
||||||
|
HORIZON_CONFIG.pop('default_dashboard', None)
|
||||||
|
|
||||||
|
# Update the dashboards with zaqar_ui
|
||||||
|
import openstack_dashboard.enabled
|
||||||
|
from openstack_dashboard.utils import settings
|
||||||
|
import zaqar_ui.enabled
|
||||||
|
|
||||||
|
settings.update_dashboards(
|
||||||
|
[
|
||||||
|
zaqar_ui.enabled,
|
||||||
|
openstack_dashboard.enabled,
|
||||||
|
],
|
||||||
|
HORIZON_CONFIG,
|
||||||
|
INSTALLED_APPS
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ensure any duplicate apps are removed after the update_dashboards call
|
||||||
|
INSTALLED_APPS = list(set(INSTALLED_APPS))
|
24
zaqar_ui/test/test_data.py
Normal file
24
zaqar_ui/test/test_data.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from openstack_dashboard.test.test_data import utils
|
||||||
|
|
||||||
|
|
||||||
|
def data(TEST):
|
||||||
|
# Test Data Container in Horizon
|
||||||
|
TEST.queues = utils.TestDataContainer()
|
||||||
|
|
||||||
|
# Queues
|
||||||
|
queue_dict_1 = {"uuid": 1,
|
||||||
|
"name": "test1"}
|
||||||
|
|
||||||
|
TEST.queues.add(queue_dict_1)
|
Loading…
Reference in New Issue
Block a user