"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "openstack_dashboard/dashboards/project/instances/tests.py" between
horizon-18.6.3.tar.gz and horizon-18.6.4.tar.gz

About: OpenStack Horizon (Optional Service: Dashboard) provides a web-based self-service portal to interact with underlying OpenStack services, such as launching an instance, assigning IP addresses and configuring access controls.
The "Victoria" series (maintained release).

tests.py  (horizon-18.6.3):tests.py  (horizon-18.6.4)
skipping to change at line 4596 skipping to change at line 4596
self.mock_tenant_floating_ip_release.assert_not_called() self.mock_tenant_floating_ip_release.assert_not_called()
@helpers.create_mocks({api.neutron: ('floating_ip_disassociate',)}) @helpers.create_mocks({api.neutron: ('floating_ip_disassociate',)})
def test_disassociate_floating_ip(self): def test_disassociate_floating_ip(self):
self._test_disassociate_floating_ip(is_release=False) self._test_disassociate_floating_ip(is_release=False)
@helpers.create_mocks({api.neutron: ('tenant_floating_ip_release',)}) @helpers.create_mocks({api.neutron: ('tenant_floating_ip_release',)})
def test_disassociate_floating_ip_with_release(self): def test_disassociate_floating_ip_with_release(self):
self._test_disassociate_floating_ip(is_release=True) self._test_disassociate_floating_ip(is_release=True)
def _populate_server_flavor_nova_api_ge_2_47(self, server):
flavor_id = server.flavor['id']
flavor = self.flavors.get(id=flavor_id)
server.flavor = {
'original_name': flavor.name,
'vcpus': flavor.vcpus,
'ram': flavor.ram,
'swap': flavor.swap,
'disk': flavor.disk,
'ephemeral': flavor.ephemeral,
'extra_specs': flavor.extra_specs,
}
return server
@helpers.create_mocks({api.nova: ('server_get', @helpers.create_mocks({api.nova: ('server_get',
'flavor_list', 'flavor_list',
'tenant_absolute_limits', 'tenant_absolute_limits',
'is_feature_available', 'is_feature_available',
'extension_supported')}) 'extension_supported')})
def test_instance_resize_get(self): def _test_instance_resize_get(self, server, nova_api_lt_2_47=False):
server = self.servers.first() server = self.servers.first()
self.mock_server_get.return_value = server self.mock_server_get.return_value = server
self.mock_flavor_list.return_value = self.flavors.list() self.mock_flavor_list.return_value = self.flavors.list()
self.mock_tenant_absolute_limits.return_value = self.limits['absolute'] self.mock_tenant_absolute_limits.return_value = self.limits['absolute']
self._mock_extension_supported({'DiskConfig': True, self._mock_extension_supported({'DiskConfig': True,
'ServerGroups': False}) 'ServerGroups': False})
url = reverse('horizon:project:instances:resize', args=[server.id]) url = reverse('horizon:project:instances:resize', args=[server.id])
res = self.client.get(url) res = self.client.get(url)
workflow = res.context['workflow']
self.assertTemplateUsed(res, views.WorkflowView.template_name) self.assertTemplateUsed(res, views.WorkflowView.template_name)
self.assertEqual(res.context['workflow'].name,
workflows.ResizeInstance.name)
self.assertContains(res, 'Disk Partition')
config_drive_field_label = 'Configuration Drive' config_drive_field_label = 'Configuration Drive'
self.assertNotContains(res, config_drive_field_label) self.assertNotContains(res, config_drive_field_label)
step = workflow.get_step("flavor_choice")
self.assertEqual(step.action.initial['old_flavor_name'],
self.flavors.first().name)
step = workflow.get_step("setadvancedaction")
self.assertEqual(step.action.fields['disk_config'].label,
'Disk Partition')
self.assertQuerysetEqual(workflow.steps,
['<SetFlavorChoice: flavor_choice>',
'<SetAdvanced: setadvancedaction>'])
option = '<option value="%s">%s</option>' option = '<option value="%s">%s</option>'
def is_original_flavor(server, flavor, nova_api_lt_2_47):
if nova_api_lt_2_47:
return flavor.id == server.flavor['id']
else:
return flavor.name == server.flavor['original_name']
for flavor in self.flavors.list(): for flavor in self.flavors.list():
if flavor.id == server.flavor['id']: if is_original_flavor(server, flavor, nova_api_lt_2_47):
self.assertNotContains(res, option % (flavor.id, flavor.name)) self.assertNotContains(res, option % (flavor.id, flavor.name))
else: else:
self.assertContains(res, option % (flavor.id, flavor.name)) self.assertContains(res, option % (flavor.id, flavor.name))
self.mock_server_get.assert_called_once_with(helpers.IsHttpRequest(), self.mock_server_get.assert_called_once_with(helpers.IsHttpRequest(),
server.id) server.id)
self.assert_mock_multiple_calls_with_same_arguments( self.assert_mock_multiple_calls_with_same_arguments(
self.mock_flavor_list, 2, self.mock_flavor_list, 2,
mock.call(helpers.IsHttpRequest())) mock.call(helpers.IsHttpRequest()))
self.mock_tenant_absolute_limits.assert_called_once_with( self.mock_tenant_absolute_limits.assert_called_once_with(
helpers.IsHttpRequest(), reserved=True) helpers.IsHttpRequest(), reserved=True)
self._check_extension_supported({'DiskConfig': 1, self._check_extension_supported({'DiskConfig': 1,
'ServerGroups': 1}) 'ServerGroups': 1})
def test_instance_resize_get_nova_api_lt_2_47(self):
server = self.servers.first()
self._test_instance_resize_get(server, nova_api_lt_2_47=True)
def test_instance_resize_get_nova_api_ge_2_47(self):
server = self.servers.first()
self._populate_server_flavor_nova_api_ge_2_47(server)
self._test_instance_resize_get(server)
@helpers.create_mocks({api.nova: ('server_get',)}) @helpers.create_mocks({api.nova: ('server_get',)})
def test_instance_resize_get_server_get_exception(self): def test_instance_resize_get_server_get_exception(self):
server = self.servers.first() server = self.servers.first()
self.mock_server_get.side_effect = self.exceptions.nova self.mock_server_get.side_effect = self.exceptions.nova
url = reverse('horizon:project:instances:resize', url = reverse('horizon:project:instances:resize',
args=[server.id]) args=[server.id])
res = self.client.get(url) res = self.client.get(url)
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
self.mock_server_get.assert_called_once_with( self.mock_server_get.assert_called_once_with(
helpers.IsHttpRequest(), server.id) helpers.IsHttpRequest(), server.id)
@helpers.create_mocks({api.nova: ('server_get', @helpers.create_mocks({api.nova: ('server_get',
'flavor_list',)}) 'flavor_list')})
def test_instance_resize_get_flavor_list_exception(self): def test_instance_resize_get_flavor_list_exception(self):
server = self.servers.first() server = self.servers.first()
self.mock_server_get.return_value = server self.mock_server_get.return_value = server
self.mock_flavor_list.side_effect = self.exceptions.nova self.mock_flavor_list.side_effect = self.exceptions.nova
url = reverse('horizon:project:instances:resize', url = reverse('horizon:project:instances:resize',
args=[server.id]) args=[server.id])
res = self.client.get(url) res = self.client.get(url)
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
self.mock_server_get.assert_called_once_with(helpers.IsHttpRequest(), self.mock_server_get.assert_called_once_with(helpers.IsHttpRequest(),
server.id) server.id)
self.mock_flavor_list.assert_called_once_with(helpers.IsHttpRequest()) self.mock_flavor_list.assert_called_once_with(helpers.IsHttpRequest())
# TODO(amotoki): This is requred only when nova API <=2.46 is used.
# Once server_get() uses nova API >=2.47 only, this test can be droppped.
@helpers.create_mocks({api.nova: ('server_get', @helpers.create_mocks({api.nova: ('server_get',
'flavor_list', 'flavor_list',
'flavor_get', 'flavor_get',
'tenant_absolute_limits', 'tenant_absolute_limits',
'is_feature_available', 'is_feature_available',
'extension_supported')}) 'extension_supported')})
def test_instance_resize_get_current_flavor_not_found(self): def test_instance_resize_get_current_flavor_not_found(self):
server = self.servers.first() server = self.servers.first()
self.mock_server_get.return_value = server self.mock_server_get.return_value = server
self.mock_flavor_list.return_value = [] self.mock_flavor_list.return_value = []
 End of changes. 11 change blocks. 
4 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)