Basic view tests for tuskar_boxes
Just checking that the pages actually display and use the right templates Change-Id: Ibb5f55c25510921e49485961f71fb22e7f8f8bc1
This commit is contained in:
parent
33caa32d4e
commit
bea0470a0b
@ -20,4 +20,5 @@ docutils==0.9.1
|
|||||||
oslosphinx
|
oslosphinx
|
||||||
|
|
||||||
http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon
|
http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon
|
||||||
|
http://tarballs.openstack.org/python-tuskarclient/python-tuskarclient-master.tar.gz#egg=python-tuskarclient
|
||||||
http://tarballs.openstack.org/tuskar-ui/tuskar-ui-master.tar.gz#egg=tuskar-ui
|
http://tarballs.openstack.org/tuskar-ui/tuskar-ui-master.tar.gz#egg=tuskar-ui
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import openstack_dashboard.enabled
|
|
||||||
from openstack_dashboard.utils import settings
|
from openstack_dashboard.utils import settings
|
||||||
import test.enabled
|
import test.enabled
|
||||||
from tuskar_ui.test.settings import * # noqa
|
from tuskar_ui.test.settings import * # noqa
|
||||||
|
|
||||||
|
|
||||||
INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable
|
INSTALLED_APPS = list(INSTALLED_APPS) # Make sure it's mutable
|
||||||
settings.update_dashboards([openstack_dashboard.enabled, test.enabled],
|
settings.update_dashboards([test.enabled], HORIZON_CONFIG, INSTALLED_APPS)
|
||||||
HORIZON_CONFIG, INSTALLED_APPS)
|
|
||||||
|
119
tuskar_boxes/overview/tests.py
Normal file
119
tuskar_boxes/overview/tests.py
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
# -*- coding: utf8 -*-
|
||||||
|
#
|
||||||
|
# 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 contextlib
|
||||||
|
|
||||||
|
from django.core import urlresolvers
|
||||||
|
import mock
|
||||||
|
from tuskar_ui import api
|
||||||
|
from tuskar_ui.infrastructure.overview import tests
|
||||||
|
from tuskar_ui.test import helpers
|
||||||
|
|
||||||
|
|
||||||
|
INDEX_URL = urlresolvers.reverse(
|
||||||
|
'horizon:infrastructure:overview:index')
|
||||||
|
|
||||||
|
|
||||||
|
class BoxesViewsTests(helpers.BaseAdminViewTests):
|
||||||
|
def test_index_edit_get(self):
|
||||||
|
with contextlib.nested(
|
||||||
|
tests._mock_plan(),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.list', return_value=[]),
|
||||||
|
mock.patch('tuskar_ui.api.node.Node.list', return_value=[]),
|
||||||
|
mock.patch('tuskar_ui.api.flavor.Flavor.list', return_value=[]),
|
||||||
|
):
|
||||||
|
res = self.client.get(INDEX_URL)
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/index.html')
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/role_nodes_edit.html')
|
||||||
|
|
||||||
|
def test_index_edit_post(self):
|
||||||
|
roles = [api.tuskar.Role(role)
|
||||||
|
for role in self.tuskarclient_roles.list()]
|
||||||
|
with contextlib.nested(
|
||||||
|
tests._mock_plan(),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.list', return_value=[]),
|
||||||
|
mock.patch('tuskar_ui.api.node.Node.list', return_value=[]),
|
||||||
|
mock.patch('tuskar_ui.api.flavor.Flavor.list', return_value=[]),
|
||||||
|
) as (plan, _stack_list, _node_list, _flavor_list):
|
||||||
|
plan.role_list = roles
|
||||||
|
data = {
|
||||||
|
'role-1-count': 1,
|
||||||
|
'role-1-flavor': 'baremetal',
|
||||||
|
'role-2-count': 0,
|
||||||
|
'role-2-flavor': 'baremetal',
|
||||||
|
'role-3-count': 0,
|
||||||
|
'role-3-flavor': 'baremetal',
|
||||||
|
'role-4-count': 0,
|
||||||
|
'role-4-flavor': 'baremetal',
|
||||||
|
}
|
||||||
|
res = self.client.post(INDEX_URL, data)
|
||||||
|
self.assertNoFormErrors(res)
|
||||||
|
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||||
|
api.tuskar.Plan.patch.assert_called_with(mock.ANY, plan.id, {
|
||||||
|
'Object Storage-1::Flavor': u'baremetal',
|
||||||
|
'Compute-1::Flavor': u'baremetal',
|
||||||
|
'Controller-1::Flavor': u'baremetal',
|
||||||
|
'Block Storage-1::Flavor': u'baremetal',
|
||||||
|
})
|
||||||
|
|
||||||
|
def test_index_live_get(self):
|
||||||
|
stack = api.heat.Stack(tests.TEST_DATA.heatclient_stacks.first())
|
||||||
|
stack.is_initialized = True
|
||||||
|
stack.is_deployed = True
|
||||||
|
roles = [api.tuskar.Role(role)
|
||||||
|
for role in self.tuskarclient_roles.list()]
|
||||||
|
|
||||||
|
with contextlib.nested(
|
||||||
|
tests._mock_plan(**{
|
||||||
|
'get_role_by_name.side_effect': None,
|
||||||
|
'get_role_by_name.return_value': roles[0],
|
||||||
|
}),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.get_by_plan',
|
||||||
|
return_value=stack),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.events',
|
||||||
|
return_value=[]),
|
||||||
|
) as (Plan, stack_get_mock, stack_events_mock):
|
||||||
|
res = self.client.get(INDEX_URL)
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/index.html')
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'infrastructure/overview/deployment_live.html')
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/role_nodes_live.html')
|
||||||
|
|
||||||
|
def test_index_progress_get(self):
|
||||||
|
stack = api.heat.Stack(tests.TEST_DATA.heatclient_stacks.first())
|
||||||
|
|
||||||
|
with contextlib.nested(
|
||||||
|
tests._mock_plan(),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.get_by_plan',
|
||||||
|
return_value=stack),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.is_deleting',
|
||||||
|
return_value=True),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.is_deployed',
|
||||||
|
return_value=False),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.resources',
|
||||||
|
return_value=[]),
|
||||||
|
mock.patch('tuskar_ui.api.heat.Stack.events',
|
||||||
|
return_value=[]),
|
||||||
|
):
|
||||||
|
res = self.client.get(INDEX_URL)
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/index.html')
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'infrastructure/overview/deployment_progress.html')
|
||||||
|
self.assertTemplateUsed(
|
||||||
|
res, 'tuskar_boxes/overview/role_nodes_status.html')
|
@ -21,6 +21,7 @@ from openstack_dashboard.api import base as api_base
|
|||||||
from tuskar_ui import api
|
from tuskar_ui import api
|
||||||
from tuskar_ui.infrastructure.overview import views
|
from tuskar_ui.infrastructure.overview import views
|
||||||
from tuskar_ui.utils import metering
|
from tuskar_ui.utils import metering
|
||||||
|
|
||||||
from tuskar_boxes.overview import forms
|
from tuskar_boxes.overview import forms
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user