]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-11694] Add CLI test for "ceph-deploy admin"
authorTravis Rhoden <trhoden@redhat.com>
Thu, 21 May 2015 18:36:15 +0000 (14:36 -0400)
committerTravis Rhoden <trhoden@redhat.com>
Thu, 21 May 2015 18:36:15 +0000 (14:36 -0400)
Signed-off-by: Travis Rhoden <trhoden@redhat.com>
ceph_deploy/tests/test_cli_admin.py [new file with mode: 0644]

diff --git a/ceph_deploy/tests/test_cli_admin.py b/ceph_deploy/tests/test_cli_admin.py
new file mode 100644 (file)
index 0000000..1c7b369
--- /dev/null
@@ -0,0 +1,49 @@
+import pytest
+import subprocess
+
+
+def test_help(tmpdir, cli):
+    with cli(
+        args=['ceph-deploy', 'admin', '--help'],
+        stdout=subprocess.PIPE,
+        ) as p:
+        result = p.stdout.read()
+    assert 'usage: ceph-deploy admin' in result
+    assert 'positional arguments' in result
+    assert 'optional arguments' in result
+
+
+def test_bad_no_hosts(tmpdir, cli):
+    with pytest.raises(cli.Failed) as err:
+        with cli(
+            args=['ceph-deploy', 'admin'],
+            stderr=subprocess.PIPE,
+            ) as p:
+            result = p.stderr.read()
+    assert 'usage: ceph-deploy admin' in result
+    assert 'too few arguments' in result
+    assert err.value.status == 2
+
+
+def test_bad_no_conf(tmpdir, cli):
+    with pytest.raises(cli.Failed) as err:
+        with cli(
+            args=['ceph-deploy', 'admin', 'host1'],
+            stderr=subprocess.PIPE,
+            ) as p:
+            result = p.stderr.read()
+    assert 'No such file or directory: \'ceph.conf\'' in result
+    assert err.value.status == 1
+
+
+def test_bad_no_key(tmpdir, cli):
+    with tmpdir.join('ceph.conf').open('w'):
+        pass
+    with pytest.raises(cli.Failed) as err:
+        with cli(
+            args=['ceph-deploy', 'admin', 'host1'],
+            stderr=subprocess.PIPE,
+            ) as p:
+            result = p.stderr.read()
+    assert 'ceph.client.admin.keyring not found' in result
+    assert err.value.status == 1