From: Travis Rhoden Date: Thu, 25 Jun 2015 00:05:47 +0000 (-0700) Subject: [RM-11742] Add argparse tests for gatherkeys X-Git-Tag: v1.5.26~14^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c7fa4e16805dc9e8adbd5615c610be8ba92c444;p=ceph-deploy.git [RM-11742] Add argparse tests for gatherkeys Signed-off-by: Travis Rhoden --- diff --git a/ceph_deploy/tests/parser/test_gatherkeys.py b/ceph_deploy/tests/parser/test_gatherkeys.py new file mode 100644 index 0000000..c71cc30 --- /dev/null +++ b/ceph_deploy/tests/parser/test_gatherkeys.py @@ -0,0 +1,32 @@ +import pytest + +from ceph_deploy.cli import get_parser + + +class TestParserGatherKeys(object): + + def setup(self): + self.parser = get_parser() + + def test_gather_help(self, capsys): + with pytest.raises(SystemExit): + self.parser.parse_args('gatherkeys --help'.split()) + out, err = capsys.readouterr() + assert 'usage: ceph-deploy gatherkeys' in out + assert 'positional arguments:' in out + assert 'optional arguments:' in out + + def test_gatherkeys_host_required(self, capsys): + with pytest.raises(SystemExit): + self.parser.parse_args('gatherkeys'.split()) + out, err = capsys.readouterr() + assert "error: too few arguments" in err + + def test_gatherkeys_one_host(self): + args = self.parser.parse_args('gatherkeys host1'.split()) + assert args.mon == ['host1'] + + def test_gatherkeys_multiple_hosts(self): + hostnames = ['host1', 'host2', 'host3'] + args = self.parser.parse_args(['gatherkeys'] + hostnames) + assert args.mon == hostnames