Fix bug in rlib2 unit tests
authorMichele Tartara <mtartara@google.com>
Thu, 21 Mar 2013 15:54:43 +0000 (16:54 +0100)
committerMichele Tartara <mtartara@google.com>
Fri, 22 Mar 2013 15:06:12 +0000 (16:06 +0100)
commit61f8fda42d732f7e7326bcbc2f3e03b0967832d2
treed350eb06bacee7e138e5abe7a4d679b71cb26b45
parentfb409531d044a4d6eefdf1faeb80bde1812854d8
Fix bug in rlib2 unit tests

The "queryargs" parameter of the __init__ function of rlib2 classes should
be a dictionary, as defined in the ResourceBase parent class (in
lib/rapi/baserlib.py).

In the rlib2 and baserlib unit tests, when the queryargs parameter is not
actually needed, it is sometimes erroneously initialized with an empty list or a
"None" value instead of an empty dictionary.

This commit solves the problem and introduces an assertion to prevent it from
happening again in the future.
The use of the assertion is safe, because in production code the __init__
function is only called by the RAPI server, with the queryargs parameter
initialized by the Mapper.getController function (lib/rapi/connector.py) that
always returns a dictionary. It can only affect test code and future code.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
lib/rapi/baserlib.py
test/py/ganeti.rapi.baserlib_unittest.py
test/py/ganeti.rapi.rlib2_unittest.py