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