From: Travis Rhoden Date: Thu, 25 Jun 2015 23:55:31 +0000 (-0700) Subject: [RM-11742] Add argparse tests for ceph-deploy calamari X-Git-Tag: v1.5.26~14^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df7c5c2def8341d73a109426d5289b2e705995ca;p=ceph-deploy.git [RM-11742] Add argparse tests for ceph-deploy calamari Signed-off-by: Travis Rhoden --- diff --git a/ceph_deploy/tests/parser/test_calamari.py b/ceph_deploy/tests/parser/test_calamari.py new file mode 100644 index 0000000..509cb7c --- /dev/null +++ b/ceph_deploy/tests/parser/test_calamari.py @@ -0,0 +1,40 @@ +import pytest + +from ceph_deploy.cli import get_parser + + +class TestParserCalamari(object): + + def setup(self): + self.parser = get_parser() + + def test_calamari_help(self, capsys): + with pytest.raises(SystemExit): + self.parser.parse_args('calamari --help'.split()) + out, err = capsys.readouterr() + assert 'usage: ceph-deploy calamari' in out + assert 'positional arguments:' in out + assert 'optional arguments:' in out + + def test_calamari_connect_host_required(self, capsys): + with pytest.raises(SystemExit): + self.parser.parse_args('calamari connect'.split()) + out, err = capsys.readouterr() + assert "error: too few arguments" in err + + def test_calamari_connect_one_host(self): + args = self.parser.parse_args('calamari connect host1'.split()) + assert args.hosts == ['host1'] + + def test_calamari_connect_multiple_hosts(self): + hostnames = ['host1', 'host2', 'host3'] + args = self.parser.parse_args('calamari connect'.split() + hostnames) + assert args.hosts == hostnames + + def test_calamari_connect_master_default_is_none(self): + args = self.parser.parse_args('calamari connect host1'.split()) + assert args.master is None + + def test_calamari_connect_master_custom(self): + args = self.parser.parse_args('calamari connect --master master.ceph.com host1'.split()) + assert args.master == "master.ceph.com"