Comment 20 for bug 1573479

Revision history for this message
Zhang Yun (zhangyun) wrote :

I tired to modify the code of Kilo release to fix this issue as below:

Change /usr/share/openstack-dashboard/openstack_dashboard/dashboards/identity/users/forms.py

Original:
    201 try:
    202 if "email" in data:
    203 data['email'] = data['email'] or None

Modified:
    201 try:
    202 if "email" in data:
    203 data['email'] = data['email'] or ''

Then restart the httpd service. This issue has gone.

But when running the UT for this new changed file, I failed the Jenkins with py27 test. Below is my modified UT code and the prompts error:

Could some one can help me on this? It has troubled me some days. Thanks a lot!

Change /usr/share/openstack-dashboard/openstack_dashboard/dashboards/identity/users/tests.py
Original:
346 formData = {'method': 'UpdateUserForm', 347
347 'id': user.id,
348 'name': user.name,
349 'email': "",
350 'project': self.tenant.id}

Modified:
346 formData = {'method': 'UpdateUserForm', 347
347 'id': user.id,
348 'name': user.name,
349 'email': '', ---> changed here
350 'project': self.tenant.id}

The UT promots error as below:
======================================================================
FAIL: test_update_with_no_email_attribute (openstack_dashboard.dashboards.identity.users.tests.UsersViewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/openstack_dashboard/test/helpers.py", line 112, in instance_stub_out
    return fn(self, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/openstack_dashboard/dashboards/identity/users/tests.py", line 353, in test_update_with_no_email_attribute
    res = self.client.post(USER_UPDATE_URL, formData)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/test/client.py", line 482, in post
    secure=secure, **extra)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/test/client.py", line 296, in post
    secure=secure, **extra)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/test/client.py", line 358, in generic
    return self.request(**r)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/test/client.py", line 440, in request
    six.reraise(*exc_info)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/decorators.py", line 36, in dec
    return view_func(request, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/decorators.py", line 52, in dec
    return view_func(request, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/decorators.py", line 36, in dec
    return view_func(request, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/openstack_dashboard/dashboards/identity/users/views.py", line 85, in dispatch
    return super(UpdateView, self).dispatch(*args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/django/views/generic/edit.py", line 173, in post
    return self.form_valid(form)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/forms/views.py", line 173, in form_valid
    exceptions.handle(self.request)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/exceptions.py", line 385, in handle
    six.reraise(exc_type, exc_value, exc_traceback)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/forms/views.py", line 170, in form_valid
    handled = form.handle(self.request, form.cleaned_data)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/openstack_dashboard/dashboards/identity/users/forms.py", line 217, in handle
    response = exceptions.handle(request, ignore=True)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/horizon/exceptions.py", line 385, in handle
    six.reraise(exc_type, exc_value, exc_traceback)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/openstack_dashboard/dashboards/identity/users/forms.py", line 209, in handle
    response = api.keystone.user_update(request, user, **data)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/mox.py", line 765, in __call__
    return mock_method(*params, **named_params)
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/mox.py", line 1002, in __call__
    expected_method = self._VerifyMethodCall()
  File "/home/jenkins/workspace/gerrit-horizon-es-py27/.tox/py27/local/lib/python2.7/site-packages/mox.py", line 1060, in _VerifyMethodCall
    raise UnexpectedMethodCallError(self, expected)
UnexpectedMethodCallError: Unexpected method call. unexpected:- expected:+
- user_update.__call__(<class 'django.http.HttpRequest'>, u'5', email='', name=u'user_five', project=u'1') -> None
? - ^^ - -

+ user_update.__call__(<class 'django.http.request.HttpRequest'>, '5', email=None, name='user_five', project='1') -> None
? ++++++++ ^^^^

>> raise UnexpectedMethodCallError(self, expected)