[openstack-dev] A proposal for code reduction
FERNANDO LOPEZ AGUILAR
fla at tid.es
Wed May 21 11:35:49 UTC 2014
Hi Abhijeet,
Why do not use the oslo library for it? I mean, maybe you can define or find a specific class related to testing process there, where you can put this method.
De: Abhijeet Jain <abhijeet.jain at nectechnologies.in<mailto:abhijeet.jain at nectechnologies.in>>
Responder a: "OpenStack Development Mailing List (not for usage questions)" <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
Fecha: Wednesday 21 May 2014 13:27
Para: "openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>" <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
Asunto: [openstack-dev] A proposal for code reduction
Hi Openstack-developers,
I am Abhijeet Jain. One of the contributor in OpenStack.
I was just working on optimizing the codes in Neutron , Keystone, Cinder modules.
Then, I came across with a very common scenario that I can see at many places.
at many places, I saw that the users have written the code in such form :
assertEqual(user1['id'], user2['id']);
assertEqual(user1['name'], user2['name']);
assertEqual(user1['status'], user2['status']);
assertEqual(user1['xyz'], user2['xyz']);
To optimize such redundancy, I created a help function like below :
def _check(self, expected, actual, keys):
for key in keys:
assertEqual( expected[key], actual[key])
So, everywhere we just need to call this function like this :
_check(user1, user2, ['id', 'name', 'status', 'xyz'])
So, this way lots of code can be reduced.
but, currently i need to put that function in every test file , I want to use. There is no global space.
My proposal is :
How about putting this function in some utils like place, which can be accessed in every test function.
but for that, I need your approval.
Kindly, provide your valuable feedback on this.
Thanks,
Abhijeet Jain
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NEC or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NEC or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
________________________________
Este mensaje se dirige exclusivamente a su destinatario. Puede consultar nuestra política de envío y recepción de correo electrónico en el enlace situado más abajo.
This message is intended exclusively for its addressee. We only send and receive email on the basis of the terms set out at:
http://www.tid.es/ES/PAGINAS/disclaimer.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140521/356d5521/attachment.html>
More information about the OpenStack-dev
mailing list