Skip to content

Commit

Permalink
Massive UI fixes + bugfixes.
Browse files Browse the repository at this point in the history
All forms/modals on the site now inherit from a single
standardized modal base template.

All cancel buttons now go to appropriate pages.

All buttons are styled approriately

Fixed many bugs in the networks, volumes and users panels.

Generally made everything more standardized, uniform, and DRY.

Moved mox.VerifyAll() to global tearDown() method to prevent
tests carelessly forgetting it, and/or VerifyAll() raising
errors that prevent UnsetStubs() from running properly.

Fixed a lot of failing unit tests that weren't being verified.

Change-Id: I9f7a87870a89f83373cd480255b0906c00cff032
  • Loading branch information
gabrielhurley committed Nov 17, 2011
1 parent 195b70b commit af2b1be
Show file tree
Hide file tree
Showing 169 changed files with 833 additions and 1,856 deletions.
3 changes: 2 additions & 1 deletion horizon/horizon/api/quantum.py
Expand Up @@ -26,6 +26,7 @@
from django.conf import settings
from quantum import client as quantum_client

from horizon.api import nova
from horizon.api.base import *
from horizon.api.deprecated import extras_api

Expand Down Expand Up @@ -111,7 +112,7 @@ def get_vif_ids(request):
attached_vifs.append(
port_attachment['attachment']['id'].encode('ascii'))
# Get all instances
instances = server_list(request)
instances = nova.server_list(request)
# Get virtual interface ids by instance
for instance in instances:
id = instance.id
Expand Down
6 changes: 4 additions & 2 deletions horizon/horizon/dashboards/nova/containers/forms.py
Expand Up @@ -107,7 +107,8 @@ def handle(self, request, data):
self.files['object_file'].read())

messages.success(request, _("Object was successfully uploaded."))
return shortcuts.redirect(request.build_absolute_uri())
return shortcuts.redirect("horizon:nova:containers:object_index",
data['container_name'])


class CopyObject(forms.SelfHandlingForm):
Expand Down Expand Up @@ -140,4 +141,5 @@ def handle(self, request, data):
_('Object was successfully copied to %(container)s\%(obj)s') %
{"container": new_container_name, "obj": new_object_name})

return shortcuts.redirect(request.build_absolute_uri())
return shortcuts.redirect("horizon:nova:containers:object_index",
data['new_container_name'])
32 changes: 5 additions & 27 deletions horizon/horizon/dashboards/nova/containers/tests.py
Expand Up @@ -55,8 +55,6 @@ def test_index(self):
self.assertEqual(len(containers), 1)
self.assertEqual(containers[0].name, 'containerName')

self.mox.VerifyAll()

def test_delete_container(self):
formData = {'container_name': 'containerName',
'method': 'DeleteContainer'}
Expand All @@ -71,8 +69,6 @@ def test_delete_container(self):

self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)

self.mox.VerifyAll()

def test_delete_container_nonempty(self):
formData = {'container_name': 'containerName',
'method': 'DeleteContainer'}
Expand All @@ -94,8 +90,6 @@ def test_delete_container_nonempty(self):

self.assertRedirectsNoFollow(res, CONTAINER_INDEX_URL)

self.mox.VerifyAll()

def test_create_container_get(self):
res = self.client.get(reverse('horizon:nova:containers:create'))

Expand All @@ -107,10 +101,9 @@ def test_create_container_post(self):

self.mox.StubOutWithMock(api, 'swift_create_container')
api.swift_create_container(
IsA(http.HttpRequest), 'CreateContainer')
IsA(http.HttpRequest), u'containerName')

self.mox.StubOutWithMock(messages, 'success')
messages.success(IgnoreArg(), IsA(basestring))
self.mox.ReplayAll()

res = self.client.post(reverse('horizon:nova:containers:create'),
formData)
Expand Down Expand Up @@ -140,8 +133,6 @@ def test_index(self):
self.assertTemplateUsed(res, 'nova/objects/index.html')
self.assertItemsEqual(res.context['objects'], self.swift_objects)

self.mox.VerifyAll()

def test_upload_index(self):
res = self.client.get(reverse('horizon:nova:containers:object_upload',
args=[self.CONTAINER_NAME]))
Expand Down Expand Up @@ -174,11 +165,9 @@ def test_upload(self):
formData)

self.assertRedirectsNoFollow(res,
reverse('horizon:nova:containers:object_upload',
reverse('horizon:nova:containers:object_index',
args=[self.CONTAINER_NAME]))

self.mox.VerifyAll()

def test_delete(self):
OBJECT_NAME = 'objectName'
formData = {'method': 'DeleteObject',
Expand All @@ -200,8 +189,6 @@ def test_delete(self):
reverse('horizon:nova:containers:object_index',
args=[self.CONTAINER_NAME]))

self.mox.VerifyAll()

def test_download(self):
OBJECT_DATA = 'objectData'
OBJECT_NAME = 'objectName'
Expand All @@ -220,8 +207,6 @@ def test_download(self):
self.assertEqual(res.content, OBJECT_DATA)
self.assertTrue(res.has_header('Content-Disposition'))

self.mox.VerifyAll()

def test_copy_index(self):
OBJECT_NAME = 'objectName'

Expand All @@ -240,8 +225,6 @@ def test_copy_index(self):

self.assertTemplateUsed(res, 'nova/objects/copy.html')

self.mox.VerifyAll()

def test_copy(self):
NEW_CONTAINER_NAME = self.CONTAINER_NAME
NEW_OBJECT_NAME = 'newObjectName'
Expand Down Expand Up @@ -276,11 +259,8 @@ def test_copy(self):
formData)

self.assertRedirectsNoFollow(res,
reverse('horizon:nova:containers:object_copy',
args=[ORIG_CONTAINER_NAME,
ORIG_OBJECT_NAME]))

self.mox.VerifyAll()
reverse('horizon:nova:containers:object_index',
args=[NEW_CONTAINER_NAME]))

def test_filter(self):
PREFIX = 'prefix'
Expand All @@ -303,5 +283,3 @@ def test_filter(self):
formData)

self.assertTemplateUsed(res, 'nova/objects/index.html')

self.mox.VerifyAll()
9 changes: 0 additions & 9 deletions horizon/horizon/dashboards/nova/floating_ips/tests.py
Expand Up @@ -64,8 +64,6 @@ def test_index(self):
self.assertTemplateUsed(res, 'nova/floating_ips/index.html')
self.assertItemsEqual(res.context['floating_ips'], self.floating_ips)

self.mox.VerifyAll()

def test_associate(self):
self.mox.StubOutWithMock(api, 'server_list')
api.server_list = self.mox.CreateMockAnything()
Expand All @@ -80,7 +78,6 @@ def test_associate(self):
res = self.client.get(reverse('horizon:nova:floating_ips:associate',
args=[1]))
self.assertTemplateUsed(res, 'nova/floating_ips/associate.html')
self.mox.VerifyAll()

def test_associate_post(self):
server = self.server
Expand Down Expand Up @@ -115,7 +112,6 @@ def test_associate_post(self):
'method': 'FloatingIpAssociate'})

self.assertRedirects(res, FLOATING_IPS_INDEX)
self.mox.VerifyAll()

def test_associate_post_with_exception(self):
server = self.server
Expand Down Expand Up @@ -155,13 +151,10 @@ def test_associate_post_with_exception(self):

self.assertRedirects(res, FLOATING_IPS_INDEX)

self.mox.VerifyAll()

def test_disassociate(self):
res = self.client.get(reverse('horizon:nova:floating_ips:disassociate',
args=[1]))
self.assertTemplateUsed(res, 'nova/floating_ips/associate.html')
self.mox.VerifyAll()

def test_disassociate_post(self):
self.mox.StubOutWithMock(api, 'tenant_floating_ip_list')
Expand All @@ -186,7 +179,6 @@ def test_disassociate_post(self):
{'floating_ip_id': self.floating_ip.id,
'method': 'FloatingIpDisassociate'})
self.assertRedirects(res, FLOATING_IPS_INDEX)
self.mox.VerifyAll()

def test_disassociate_post_with_exception(self):
self.mox.StubOutWithMock(api, 'tenant_floating_ip_list')
Expand All @@ -213,4 +205,3 @@ def test_disassociate_post_with_exception(self):
'method': 'FloatingIpDisassociate'})
self.assertRaises(novaclient_exceptions.ClientException)
self.assertRedirects(res, FLOATING_IPS_INDEX)
self.mox.VerifyAll()
18 changes: 0 additions & 18 deletions horizon/horizon/dashboards/nova/images/tests.py
Expand Up @@ -84,8 +84,6 @@ def test_index(self):
self.assertEqual(len(images), 1)
self.assertEqual(images[0].name, 'visibleImage')

self.mox.VerifyAll()

def test_index_no_images(self):
self.mox.StubOutWithMock(api, 'image_list_detailed')
api.image_list_detailed(IsA(http.HttpRequest)).AndReturn([])
Expand All @@ -103,8 +101,6 @@ def test_index_no_images(self):

self.assertTemplateUsed(res, 'nova/images/index.html')

self.mox.VerifyAll()

def test_index_client_conn_error(self):
self.mox.StubOutWithMock(api, 'image_list_detailed')
exception = glance_exception.ClientConnectionError('clientConnError')
Expand All @@ -124,8 +120,6 @@ def test_index_client_conn_error(self):
self.assertTemplateUsed(res,
'nova/images/index.html')

self.mox.VerifyAll()

def test_index_glance_error(self):
self.mox.StubOutWithMock(api, 'image_list_detailed')
exception = glance_exception.Error('glanceError')
Expand All @@ -144,8 +138,6 @@ def test_index_glance_error(self):

self.assertTemplateUsed(res, 'nova/images/index.html')

self.mox.VerifyAll()

def test_launch_get(self):
IMAGE_ID = '1'

Expand Down Expand Up @@ -186,8 +178,6 @@ def test_launch_get(self):
self.assertEqual(form_keyfield.choices[0][0],
self.keypairs[0].name)

self.mox.VerifyAll()

def test_launch_post(self):
FLAVOR_ID = self.flavors[0].id
IMAGE_ID = '1'
Expand Down Expand Up @@ -249,8 +239,6 @@ def test_launch_post(self):
self.assertRedirectsNoFollow(res,
reverse('horizon:nova:instances:index'))

self.mox.VerifyAll()

def test_launch_flavorlist_error(self):
IMAGE_ID = '1'

Expand Down Expand Up @@ -285,8 +273,6 @@ def test_launch_flavorlist_error(self):
form_flavorfield = form.fields['flavor']
self.assertIn('m1.tiny', form_flavorfield.choices[0][1])

self.mox.VerifyAll()

def test_launch_keypairlist_error(self):
IMAGE_ID = '2'

Expand Down Expand Up @@ -321,8 +307,6 @@ def test_launch_keypairlist_error(self):
form_keyfield = form.fields['key_name']
self.assertEqual(len(form_keyfield.choices), 0)

self.mox.VerifyAll()

def test_launch_form_apiexception(self):
FLAVOR_ID = self.flavors[0].id
IMAGE_ID = '1'
Expand Down Expand Up @@ -382,5 +366,3 @@ def test_launch_form_apiexception(self):
res = self.client.post(url, form_data)

self.assertTemplateUsed(res, 'nova/images/launch.html')

self.mox.VerifyAll()

0 comments on commit af2b1be

Please sign in to comment.