Merge "Do not use empty description fields"

This commit is contained in:
Jenkins 2015-12-07 13:24:23 +00:00 committed by Gerrit Code Review
commit 53a65af5b8
2 changed files with 46 additions and 5 deletions

View File

@ -151,7 +151,7 @@ class CreateUserForm(PasswordMixin, BaseUserForm):
api.keystone.user_create(request,
name=data['name'],
email=data['email'],
description=desc,
description=desc or None,
password=data['password'],
project=data['project'] or None,
enabled=data['enabled'],
@ -223,6 +223,9 @@ class UpdateUserForm(BaseUserForm):
data.pop('domain_id')
data.pop('domain_name')
if 'description' not in self.changed_data:
data.pop('description')
try:
if "email" in data:
data['email'] = data['email'] or None

View File

@ -307,8 +307,7 @@ class UsersViewTests(test.BaseAdminViewTests):
user.id,
email=user.email,
name=user.name,
project=self.tenant.id,
description=user.description).AndReturn(None)
project=self.tenant.id).AndReturn(None)
self.mox.ReplayAll()
@ -346,8 +345,7 @@ class UsersViewTests(test.BaseAdminViewTests):
user.id,
email=user.email,
name=user.name,
project=self.tenant.id,
description=user.description).AndReturn(None)
project=self.tenant.id).AndReturn(None)
self.mox.ReplayAll()
@ -648,6 +646,46 @@ class UsersViewTests(test.BaseAdminViewTests):
self.assertEqual(res.context['form']['domain_name'].value(),
domain.name)
@test.create_stubs({api.keystone: ('user_get',
'domain_get',
'tenant_list',
'user_update_tenant',
'user_update_password',
'user_update',
'roles_for_user', )})
def test_update_different_description(self):
user = self.users.get(id="1")
domain_id = user.domain_id
domain = self.domains.get(id=domain_id)
api.keystone.user_get(IsA(http.HttpRequest), '1',
admin=True).AndReturn(user)
api.keystone.domain_get(IsA(http.HttpRequest),
domain_id).AndReturn(domain)
api.keystone.tenant_list(IgnoreArg(),
domain=domain_id,
user=user.id) \
.AndReturn([self.tenants.list(), False])
api.keystone.user_update(IsA(http.HttpRequest),
user.id,
email=user.email,
name=user.name,
project=self.tenant.id,
description='changed').AndReturn(None)
self.mox.ReplayAll()
formData = {'method': 'UpdateUserForm',
'id': user.id,
'name': user.name,
'description': 'changed',
'email': user.email,
'project': self.tenant.id}
res = self.client.post(USER_UPDATE_URL, formData)
self.assertNoFormErrors(res)
class SeleniumTests(test.SeleniumAdminTestCase):
def _get_default_domain(self):