Merge "Fix unit test indentation and the test itself"

This commit is contained in:
Jenkins 2016-08-25 18:46:40 +00:00 committed by Gerrit Code Review
commit 2ffc81fcb6
1 changed files with 32 additions and 33 deletions

View File

@ -25,7 +25,6 @@ from django.utils import timezone
from mox3.mox import IgnoreArg # noqa from mox3.mox import IgnoreArg # noqa
from mox3.mox import IsA # noqa from mox3.mox import IsA # noqa
from horizon import exceptions
from horizon.workflows import views from horizon.workflows import views
from openstack_auth import policy as policy_backend from openstack_auth import policy as policy_backend
@ -1498,41 +1497,41 @@ class UpdateProjectWorkflowTests(test.BaseAdminViewTests):
self.assertMessageCount(error=2, warning=1) self.assertMessageCount(error=2, warning=1)
self.assertRedirectsNoFollow(res, INDEX_URL) self.assertRedirectsNoFollow(res, INDEX_URL)
@test.create_stubs({api.keystone: ('get_default_role', @test.create_stubs({api.keystone: ('get_default_role',
'tenant_get', 'tenant_get',
'domain_get'), 'domain_get'),
quotas: ('get_tenant_quota_data', quotas: ('get_tenant_quota_data',
'get_disabled_quotas')}) 'get_disabled_quotas')})
def test_update_project_when_default_role_does_not_exist(self): def test_update_project_when_default_role_does_not_exist(self):
project = self.tenants.first() project = self.tenants.first()
domain_id = project.domain_id domain_id = project.domain_id
quota = self.quotas.first() quota = self.quotas.first()
api.keystone.get_default_role(IsA(http.HttpRequest)) \ api.keystone.get_default_role(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(None) # Default role doesn't exist .MultipleTimes().AndReturn(None) # Default role doesn't exist
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id, api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id,
admin=True) \ admin=True).AndReturn(project)
.AndReturn(project) api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \
api.keystone.domain_get(IsA(http.HttpRequest), domain_id) \ .AndReturn(self.domain)
.AndReturn(self.domain) quotas.get_disabled_quotas(IsA(http.HttpRequest)) \
quotas.get_disabled_quotas(IsA(http.HttpRequest)) \ .AndReturn(self.disabled_quotas.first())
.AndReturn(self.disabled_quotas.first()) quotas.get_tenant_quota_data(IsA(http.HttpRequest),
quotas.get_tenant_quota_data(IsA(http.HttpRequest), tenant_id=self.tenant.id).AndReturn(quota)
tenant_id=self.tenant.id) \ self.mox.ReplayAll()
.AndReturn(quota)
self.mox.ReplayAll()
url = reverse('horizon:identity:projects:update', url = reverse('horizon:identity:projects:update',
args=[self.tenant.id]) args=[self.tenant.id])
try: try:
# Avoid the log message in the test output when the workflow's # Avoid the log message in the test output when the workflow's
# step action cannot be instantiated # step action cannot be instantiated
logging.disable(logging.ERROR) logging.disable(logging.ERROR)
with self.assertRaises(exceptions.NotFound): res = self.client.get(url)
self.client.get(url) finally:
finally: logging.disable(logging.NOTSET)
logging.disable(logging.NOTSET)
self.assertNoFormErrors(res)
self.assertMessageCount(error=1, warning=0)
class UsageViewTests(test.BaseAdminViewTests): class UsageViewTests(test.BaseAdminViewTests):