-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard-openlmi.rhcloud.com/r/847/#review1154
-----------------------------------------------------------
src/journald/test/TestIterators.py
<
http://reviewboard-openlmi.rhcloud.com/r/847/#comment686>
IMHO this is more readable:
self.assertEqual(retval, 0)
src/journald/test/TestIterators.py
<
http://reviewboard-openlmi.rhcloud.com/r/847/#comment685>
Wow, I wonder whether this id is unique enough... :-D
IPv6 address sucks!
src/journald/test/TestIterators.py
<
http://reviewboard-openlmi.rhcloud.com/r/847/#comment687>
unittest has means even for exception handling:
with self.assertRaises(pywbem.CIMError) as cm:
func(*args, **kwds)
self.assertEqual(pywbem.CIM_ERR_INVALID_PARAMETER, cm.exception.args[0])
And since this is a common use case in your test, you may save a lot by defining this
method:
def assertRaisesCIM(self, cim_err_code, func, *args, **kwds):
"""
This test passes if given function called with supplied arguements
raises pywbem.CIMError with given cim error code.
"""
with self.assertRaises(pywbem.CIMError) as cm:
func(*args, **kwds)
self.assertEqual(cim_err_code, cm.exception.args[0])
resulting in:
self.assertRaisesCIM(pywbem.CIM_ERR_INVALID_PARAMETER,
self.wbemconnection.InvokeMethod,
MethodName="CancelIteration",
ObjectName=inst.path,
IterationIdentifier=rfirst['IterationIdentifier'])
src/journald/test/list-journal
<
http://reviewboard-openlmi.rhcloud.com/r/847/#comment688>
I know it's a bit more code, but makes it usable elsewhere:
url = os.environ.get('LMI_CIMOM_URL', 'localhost')
username = os.environ.get('LMI_CIMOM_USERNAME', "pegasus")
password = os.environ.get('LMI_CIMOM_PASSWORD', "heslo")
c = connect(url, username, password)
- Michal Minar
On Sept. 10, 2013, 2:32 p.m., Tomáš Bžatek wrote:
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard-openlmi.rhcloud.com/r/847/
-----------------------------------------------------------
(Updated Sept. 10, 2013, 2:32 p.m.)
Review request for OpenLMI Developers.
Repository: openlmi-providers
Description
-------
journald: Add iterator tests
Tests basic iterator operations, assumes accessible journal and several (> 10)
records available.
Also comes with a simple example script for downloading complete journal.
--
This is the largest chunk of Python code I've ever written! \o/
Diffs
-----
src/journald/test/TestIterators.py PRE-CREATION
src/journald/test/list-journal PRE-CREATION
Diff:
http://reviewboard-openlmi.rhcloud.com/r/847/diff/
Testing
-------
Thanks,
Tomáš Bžatek