]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
pybind: ceph_argparse unit tests foundations
authorLoic Dachary <loic@dachary.org>
Sun, 15 Sep 2013 15:19:41 +0000 (17:19 +0200)
committerLoic Dachary <loic@dachary.org>
Mon, 23 Sep 2013 21:46:44 +0000 (23:46 +0200)
commit1d54754c48c76cc9324c6ea83c0f17987a657fc4
tree60676bf6b675d061d0a4709cadf43db7c5f53d0c
parentf9c7bc697ce99479ecbcb47571e416ceb53d6bf3
pybind: ceph_argparse unit tests foundations

The general idea is to have a series of commands, in the same order as
they show in mon/MonCommands.h, as if they were input to the ceph
client. For each command a valid combination is verified. And at least
one validation error is checked to produce a validation error. For
instance:

    ['pg', 'stat']

is a valid command and the validate_command function is expected to
return a value that is not None or {}. The command

    ['pg', 'stat', 'toomany' ]

is also given to validate_command to check that an error occurs when
an extra argument is given.

The TestArparse class implements a few methods to reduce the verbosity
of the tests. It does not provide many methods : only those that
significantly reduce the verbosity have been implemented. The drawback
of writing too many convenience methods is that they are more difficult
to read and maintain.

The signature dictionary is made a global variable so that
it is only extracted once for all classes. It is immutable.

http://tracker.ceph.com/issues/6274 refs #6274

Reviewed-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/pybind/test_ceph_argparse.py