-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 21/05/14 13:20, Abhijeet Jain wrote: > > > 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']); >
Have you really seen lots of cases like that? I can't recollect any such occurrences that would require a global check function in e.g. oslo and neutron code. > > 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']) > The semantics of the function is not clear from its name. I also doubt its usefulness outside specific test cases that require such a check. > 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. > You can try to put it in BaseTestCase class. Also see [1] for a new oslo library that should eventually replace all base test classes in openstack projects. [1]: https://github.com/openstack/oslo.test > 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. People generally don't send confidential contents to public lists. :) > 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. . > ----------------------------------------------------------------------------------------------------------------------- > > > > > _______________________________________________ OpenStack-dev > mailing list [email protected] > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev > -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCgAGBQJTfJpIAAoJEC5aWaUY1u5726MIAMsqqD93pt9/Ee72VRB04k+3 uEFeOwGwZGwgeWqBx/VldV0H2PPnLsRFSNkuYy3+SdzkKubsf+DsklJx/88iWDa2 Aq1PkcCpFwBQgM05HyExe1x9TR+vCnhBAsU12GDqjQEvxBP3L/M+RTFT4keb+Kjt STQ05k21Nc2q2/a7TNU4CKfMB6rD1dLshIdXTTcpHFDJ3qh9jgnpI2xWUtMAT4Ow Na2l773f4zZYkeapcPjcI2otRZQPleZEnayp47O4arI3/3LssB9nfU1G9lWyhk0d iEs506Ma7b1sLAlanS6l3vgmRLrDV7I2POHJH2gmQ6xVFupl4yoFHIR1j/SNw+c= =KZBD -----END PGP SIGNATURE----- _______________________________________________ OpenStack-dev mailing list [email protected] http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
