Merge "Remove mox3 from TemplateGeneratorTests"
This commit is contained in:
commit
b3b9e2896a
@ -13,9 +13,6 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from mox3.mox import IsA
|
|
||||||
|
|
||||||
from django import http
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from openstack_dashboard import api as dashboard_api
|
from openstack_dashboard import api as dashboard_api
|
||||||
|
|
||||||
@ -25,12 +22,14 @@ from heat_dashboard.test import helpers as test
|
|||||||
|
|
||||||
class TemplateGeneratorTests(test.TestCase):
|
class TemplateGeneratorTests(test.TestCase):
|
||||||
|
|
||||||
|
use_mox = False
|
||||||
|
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
self.client.get(reverse('horizon:project:template_generator:index'))
|
self.client.get(reverse('horizon:project:template_generator:index'))
|
||||||
self.assertTemplateUsed(
|
self.assertTemplateUsed(
|
||||||
template_name='project/template_generator/index.html')
|
template_name='project/template_generator/index.html')
|
||||||
|
|
||||||
@test.create_stubs({
|
@test.create_mocks({
|
||||||
api.heat: ('template_version_list', ),
|
api.heat: ('template_version_list', ),
|
||||||
dashboard_api.neutron: (
|
dashboard_api.neutron: (
|
||||||
'network_list', 'subnet_list', 'tenant_floating_ip_list',
|
'network_list', 'subnet_list', 'tenant_floating_ip_list',
|
||||||
@ -60,41 +59,23 @@ class TemplateGeneratorTests(test.TestCase):
|
|||||||
keypairs = self.keypairs.list()
|
keypairs = self.keypairs.list()
|
||||||
template_versions = self.template_versions.list()
|
template_versions = self.template_versions.list()
|
||||||
|
|
||||||
dashboard_api.cinder.volume_list(
|
self.mock_volume_list.return_value = volumes
|
||||||
IsA(http.HttpRequest)).AndReturn(volumes)
|
self.mock_volume_snapshot_list.return_value = volume_snapshots
|
||||||
dashboard_api.cinder.volume_snapshot_list(
|
self.mock_volume_type_list.return_vlue = volume_types
|
||||||
IsA(http.HttpRequest)).AndReturn(volume_snapshots)
|
self.mock_volume_backup_list.return_value = volume_backups
|
||||||
dashboard_api.cinder.volume_type_list(
|
self.mock_image_list_detailed.return_value = images
|
||||||
IsA(http.HttpRequest)).AndReturn(volume_types)
|
self.mock_network_list.return_value = networks
|
||||||
dashboard_api.cinder.volume_backup_list(
|
self.mock_subnet_list.return_value = subnets
|
||||||
IsA(http.HttpRequest)).AndReturn(volume_backups)
|
self.mock_tenant_floating_ip_list.return_value = floating_ips
|
||||||
dashboard_api.glance.image_list_detailed(
|
self.mock_port_list.return_value = ports
|
||||||
IsA(http.HttpRequest)).AndReturn(images)
|
self.mock_security_group_list.return_value = security_groups
|
||||||
dashboard_api.neutron.network_list(
|
self.mock_router_list.return_value = routers
|
||||||
IsA(http.HttpRequest)).AndReturn(networks)
|
self.mock_policy_list.return_value = qos_policies
|
||||||
dashboard_api.neutron.subnet_list(
|
self.mock_availability_zone_list.return_value = availability_zones
|
||||||
IsA(http.HttpRequest)).AndReturn(subnets)
|
self.mock_flavor_list.return_value = flavors
|
||||||
dashboard_api.neutron.tenant_floating_ip_list(
|
self.mock_server_list.return_value = instances
|
||||||
IsA(http.HttpRequest), True).AndReturn(floating_ips)
|
self.mock_keypair_list.return_value = keypairs
|
||||||
dashboard_api.neutron.port_list(
|
self.mock_template_version_list.return_value = template_versions
|
||||||
IsA(http.HttpRequest)).AndReturn(ports)
|
|
||||||
dashboard_api.neutron.security_group_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(security_groups)
|
|
||||||
dashboard_api.neutron.router_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(routers)
|
|
||||||
dashboard_api.neutron.policy_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(qos_policies)
|
|
||||||
dashboard_api.nova.availability_zone_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(availability_zones)
|
|
||||||
dashboard_api.nova.flavor_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(flavors)
|
|
||||||
dashboard_api.nova.server_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(instances)
|
|
||||||
dashboard_api.nova.keypair_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(keypairs)
|
|
||||||
api.heat.template_version_list(
|
|
||||||
IsA(http.HttpRequest)).AndReturn(template_versions)
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
|
|
||||||
resp = self.client.get(reverse(
|
resp = self.client.get(reverse(
|
||||||
'horizon:project:template_generator:apis'))
|
'horizon:project:template_generator:apis'))
|
||||||
@ -103,3 +84,38 @@ class TemplateGeneratorTests(test.TestCase):
|
|||||||
data = data.decode('utf-8')
|
data = data.decode('utf-8')
|
||||||
json_data = json.loads(data)
|
json_data = json.loads(data)
|
||||||
self.assertEqual(len(json_data.keys()), 20)
|
self.assertEqual(len(json_data.keys()), 20)
|
||||||
|
|
||||||
|
self.mock_volume_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_volume_snapshot_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_volume_backup_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_image_list_detailed.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_network_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_subnet_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_tenant_floating_ip_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest(), True)
|
||||||
|
self.mock_port_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_security_group_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_router_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_policy_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_flavor_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_server_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_keypair_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
self.mock_template_version_list.assert_called_once_with(
|
||||||
|
test.IsHttpRequest())
|
||||||
|
Loading…
Reference in New Issue
Block a user