Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix IndexError when trying to create the first flavor (bug 959232)
this happens when all the default flavors have been deleted and a user tries to add a new one through the WebUI Change-Id: Ic7779ac2ead409626c1b6ec0540865629e78277e
- Loading branch information
Showing
2 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django import http | ||
from django.core import urlresolvers | ||
from mox import IsA | ||
|
||
from horizon import api | ||
from horizon.tests.base_tests import BaseHorizonTests | ||
|
||
|
||
class FlavorsTests(BaseHorizonTests): | ||
def test_create_new_flavor_when_none_exist(self): | ||
# Set admin role | ||
self.setActiveUser(token=self.token.id, | ||
username=self.user.name, | ||
tenant_id=self.tenant.id, | ||
service_catalog=self.request.user.service_catalog, | ||
roles=[{'name': 'admin'}]) | ||
|
||
self.mox.StubOutWithMock(api, 'flavor_list') | ||
# no pre-existing flavors | ||
api.flavor_list(IsA(http.HttpRequest)).AndReturn([]) | ||
self.mox.ReplayAll() | ||
|
||
resp = self.client.get( | ||
urlresolvers.reverse('horizon:syspanel:flavors:create')) | ||
self.assertEqual(resp.status_code, 200) | ||
self.assertTemplateUsed(resp, "syspanel/flavors/create.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters