Fix Unit tests for trove-dashboard
After 196de449b6 merged in openstack/horizon few trove-dashboard unit tests start failing. This patch updates those unit tests to not depend on the internal implementation of the horizon network_list_for_tenant function[1]. So any change in horizon won't break these tests again. [1] https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/neutron.py#L1397 Change-Id: I20dad437b243bd71b017fc876de9fe84b654ee65
This commit is contained in:
parent
681de5d4df
commit
751974bddb
@ -189,7 +189,7 @@ class DatabasesBackupsTests(test.TestCase):
|
|||||||
'datastore_flavors', 'datastore_list',
|
'datastore_flavors', 'datastore_list',
|
||||||
'datastore_version_list', 'instance_list'),
|
'datastore_version_list', 'instance_list'),
|
||||||
dash_api.cinder: ('volume_type_list',),
|
dash_api.cinder: ('volume_type_list',),
|
||||||
dash_api.neutron: ('network_list',),
|
dash_api.neutron: ('network_list_for_tenant',),
|
||||||
dash_api.nova: ('availability_zone_list',),
|
dash_api.nova: ('availability_zone_list',),
|
||||||
policy: ('check',),
|
policy: ('check',),
|
||||||
})
|
})
|
||||||
@ -207,7 +207,8 @@ class DatabasesBackupsTests(test.TestCase):
|
|||||||
self.mock_instance_list.return_value = (
|
self.mock_instance_list.return_value = (
|
||||||
common.Paginated(self.databases.list()))
|
common.Paginated(self.databases.list()))
|
||||||
self.mock_volume_type_list.return_vlue = []
|
self.mock_volume_type_list.return_vlue = []
|
||||||
self.mock_network_list.return_value = self.networks.list()[:1]
|
self.mock_network_list_for_tenant.return_value = (
|
||||||
|
self.networks.list()[:1])
|
||||||
self.mock_availability_zone_list.return_value = (
|
self.mock_availability_zone_list.return_value = (
|
||||||
self.availability_zones.list())
|
self.availability_zones.list())
|
||||||
|
|
||||||
@ -228,8 +229,9 @@ class DatabasesBackupsTests(test.TestCase):
|
|||||||
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
|
self.mock_instance_list.assert_called_once_with(test.IsHttpRequest())
|
||||||
self.mock_volume_type_list.assert_called_once_with(
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_network_list.assert_any_call(
|
self.mock_network_list_for_tenant.assert_called_once_with(
|
||||||
test.IsHttpRequest(), tenant_id=self.tenant.id, shared=False)
|
test.IsHttpRequest(), self.tenant.id,
|
||||||
|
include_pre_auto_allocate=True)
|
||||||
self.mock_availability_zone_list.assert_called_once_with(
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.assertTemplateUsed(res, 'project/databases/launch.html')
|
self.assertTemplateUsed(res, 'project/databases/launch.html')
|
||||||
|
@ -137,7 +137,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
'datastore_list', 'datastore_version_list', 'flavor_list',
|
'datastore_list', 'datastore_version_list', 'flavor_list',
|
||||||
'instance_list'),
|
'instance_list'),
|
||||||
dash_api.cinder: ('volume_type_list',),
|
dash_api.cinder: ('volume_type_list',),
|
||||||
dash_api.neutron: ('network_list',),
|
dash_api.neutron: ('network_list_for_tenant',),
|
||||||
dash_api.nova: ('availability_zone_list',),
|
dash_api.nova: ('availability_zone_list',),
|
||||||
policy: ('check',),
|
policy: ('check',),
|
||||||
})
|
})
|
||||||
@ -155,8 +155,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
|
|
||||||
self.mock_volume_type_list.return_value = []
|
self.mock_volume_type_list.return_value = []
|
||||||
|
|
||||||
self.mock_network_list.side_effect = [self.networks.list()[:1],
|
self.mock_network_list_for_tenant.return_value = self.networks.list()
|
||||||
self.networks.list()[1:]]
|
|
||||||
|
|
||||||
self.mock_availability_zone_list.return_value = (
|
self.mock_availability_zone_list.return_value = (
|
||||||
self.availability_zones.list())
|
self.availability_zones.list())
|
||||||
@ -179,11 +178,9 @@ class DatabaseTests(test.TestCase):
|
|||||||
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
||||||
self.mock_volume_type_list.assert_called_once_with(
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_network_list.assert_has_calls([
|
self.mock_network_list_for_tenant.assert_called_once_with(
|
||||||
mock.call(test.IsHttpRequest(),
|
test.IsHttpRequest(), self.tenant.id,
|
||||||
tenant_id=self.tenant.id,
|
include_pre_auto_allocate=True)
|
||||||
shared=False),
|
|
||||||
mock.call(test.IsHttpRequest(), shared=True)])
|
|
||||||
self.mock_availability_zone_list.assert_called_once_with(
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.assertTemplateUsed(res, 'project/databases/launch.html')
|
self.assertTemplateUsed(res, 'project/databases/launch.html')
|
||||||
@ -225,7 +222,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
'datastore_list', 'datastore_version_list', 'flavor_list',
|
'datastore_list', 'datastore_version_list', 'flavor_list',
|
||||||
'instance_create', 'instance_list'),
|
'instance_create', 'instance_list'),
|
||||||
dash_api.cinder: ('volume_type_list',),
|
dash_api.cinder: ('volume_type_list',),
|
||||||
dash_api.neutron: ('network_list',),
|
dash_api.neutron: ('network_list_for_tenant',),
|
||||||
dash_api.nova: ('availability_zone_list',),
|
dash_api.nova: ('availability_zone_list',),
|
||||||
policy: ('check',),
|
policy: ('check',),
|
||||||
})
|
})
|
||||||
@ -242,8 +239,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
|
|
||||||
self.mock_volume_type_list.return_value = []
|
self.mock_volume_type_list.return_value = []
|
||||||
|
|
||||||
self.mock_network_list.side_effect = [self.networks.list()[:1],
|
self.mock_network_list_for_tenant.return_value = self.networks.list()
|
||||||
self.networks.list()[1:]]
|
|
||||||
|
|
||||||
nics = [{"net-id": self.networks.first().id}]
|
nics = [{"net-id": self.networks.first().id}]
|
||||||
|
|
||||||
@ -283,11 +279,9 @@ class DatabaseTests(test.TestCase):
|
|||||||
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
||||||
self.mock_volume_type_list.assert_called_once_with(
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_network_list.assert_has_calls([
|
self.mock_network_list_for_tenant.assert_called_once_with(
|
||||||
mock.call(test.IsHttpRequest(),
|
test.IsHttpRequest(), self.tenant.id,
|
||||||
tenant_id=self.tenant.id,
|
include_pre_auto_allocate=True)
|
||||||
shared=False),
|
|
||||||
mock.call(test.IsHttpRequest(), shared=True)])
|
|
||||||
self.mock_availability_zone_list.assert_called_once_with(
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_instance_create.assert_called_once_with(
|
self.mock_instance_create.assert_called_once_with(
|
||||||
@ -315,7 +309,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
'datastore_list', 'datastore_version_list', 'flavor_list',
|
'datastore_list', 'datastore_version_list', 'flavor_list',
|
||||||
'instance_create', 'instance_list'),
|
'instance_create', 'instance_list'),
|
||||||
dash_api.cinder: ('volume_type_list',),
|
dash_api.cinder: ('volume_type_list',),
|
||||||
dash_api.neutron: ('network_list',),
|
dash_api.neutron: ('network_list_for_tenant',),
|
||||||
dash_api.nova: ('availability_zone_list',),
|
dash_api.nova: ('availability_zone_list',),
|
||||||
policy: ('check',),
|
policy: ('check',),
|
||||||
})
|
})
|
||||||
@ -333,8 +327,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
|
|
||||||
self.mock_volume_type_list.return_value = []
|
self.mock_volume_type_list.return_value = []
|
||||||
|
|
||||||
self.mock_network_list.side_effect = [self.networks.list()[:1],
|
self.mock_network_list_for_tenant.return_value = self.networks.list()
|
||||||
self.networks.list()[1:]]
|
|
||||||
|
|
||||||
nics = [{"net-id": self.networks.first().id}]
|
nics = [{"net-id": self.networks.first().id}]
|
||||||
|
|
||||||
@ -374,11 +367,9 @@ class DatabaseTests(test.TestCase):
|
|||||||
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
||||||
self.mock_volume_type_list.assert_called_once_with(
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_network_list.assert_has_calls([
|
self.mock_network_list_for_tenant.assert_called_once_with(
|
||||||
mock.call(test.IsHttpRequest(),
|
test.IsHttpRequest(), self.tenant.id,
|
||||||
tenant_id=self.tenant.id,
|
include_pre_auto_allocate=True)
|
||||||
shared=False),
|
|
||||||
mock.call(test.IsHttpRequest(), shared=True)])
|
|
||||||
self.mock_availability_zone_list.assert_called_once_with(
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_instance_create.assert_called_once_with(
|
self.mock_instance_create.assert_called_once_with(
|
||||||
@ -1048,7 +1039,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
'datastore_list', 'datastore_version_list', 'flavor_list',
|
'datastore_list', 'datastore_version_list', 'flavor_list',
|
||||||
'instance_create', 'instance_get', 'instance_list_all'),
|
'instance_create', 'instance_get', 'instance_list_all'),
|
||||||
dash_api.cinder: ('volume_type_list',),
|
dash_api.cinder: ('volume_type_list',),
|
||||||
dash_api.neutron: ('network_list',),
|
dash_api.neutron: ('network_list_for_tenant',),
|
||||||
dash_api.nova: ('availability_zone_list',),
|
dash_api.nova: ('availability_zone_list',),
|
||||||
policy: ('check',),
|
policy: ('check',),
|
||||||
})
|
})
|
||||||
@ -1063,8 +1054,7 @@ class DatabaseTests(test.TestCase):
|
|||||||
|
|
||||||
self.mock_volume_type_list.return_value = []
|
self.mock_volume_type_list.return_value = []
|
||||||
|
|
||||||
self.mock_network_list.side_effect = [self.networks.list()[:1],
|
self.mock_network_list_for_tenant.return_value = self.networks.list()
|
||||||
self.networks.list()[1:]]
|
|
||||||
|
|
||||||
nics = [{"net-id": self.networks.first().id}]
|
nics = [{"net-id": self.networks.first().id}]
|
||||||
|
|
||||||
@ -1110,11 +1100,9 @@ class DatabaseTests(test.TestCase):
|
|||||||
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
||||||
self.mock_volume_type_list.assert_called_once_with(
|
self.mock_volume_type_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_network_list.assert_has_calls([
|
self.mock_network_list_for_tenant.assert_called_once_with(
|
||||||
mock.call(test.IsHttpRequest(),
|
test.IsHttpRequest(), self.tenant.id,
|
||||||
tenant_id=self.tenant.id,
|
include_pre_auto_allocate=True)
|
||||||
shared=False),
|
|
||||||
mock.call(test.IsHttpRequest(), shared=True)])
|
|
||||||
self.mock_availability_zone_list.assert_called_once_with(
|
self.mock_availability_zone_list.assert_called_once_with(
|
||||||
test.IsHttpRequest())
|
test.IsHttpRequest())
|
||||||
self.mock_instance_get.assert_called_once_with(
|
self.mock_instance_get.assert_called_once_with(
|
||||||
|
Loading…
Reference in New Issue
Block a user