]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add basic tests for scripts
authorZack Cerza <zack@cerza.org>
Wed, 9 Oct 2013 21:56:49 +0000 (16:56 -0500)
committerZack Cerza <zack@cerza.org>
Fri, 11 Oct 2013 00:09:35 +0000 (19:09 -0500)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
13 files changed:
scripts/test/script.py [new file with mode: 0644]
scripts/test/test_coverage.py [new file with mode: 0644]
scripts/test/test_lock.py [new file with mode: 0644]
scripts/test/test_ls.py [new file with mode: 0644]
scripts/test/test_nuke.py [new file with mode: 0644]
scripts/test/test_report.py [new file with mode: 0644]
scripts/test/test_results.py [new file with mode: 0644]
scripts/test/test_run.py [new file with mode: 0644]
scripts/test/test_schedule.py [new file with mode: 0644]
scripts/test/test_suite.py [new file with mode: 0644]
scripts/test/test_updatekeys.py [new file with mode: 0644]
scripts/test/test_worker.py [new file with mode: 0644]
tox.ini

diff --git a/scripts/test/script.py b/scripts/test/script.py
new file mode 100644 (file)
index 0000000..4f5aa7a
--- /dev/null
@@ -0,0 +1,16 @@
+import subprocess
+from pytest import raises
+
+
+class Script(object):
+    script_name = 'teuthology'
+
+    def test_help(self):
+        args = (self.script_name, '--help')
+        out = subprocess.check_output(args)
+        assert out.startswith('usage')
+
+    def test_invalid(self):
+        args = (self.script_name, 'INVALID')
+        with raises(subprocess.CalledProcessError):
+            subprocess.check_call(args)
diff --git a/scripts/test/test_coverage.py b/scripts/test/test_coverage.py
new file mode 100644 (file)
index 0000000..a04b9e8
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestCoverage(Script):
+    script_name = 'teuthology-coverage'
diff --git a/scripts/test/test_lock.py b/scripts/test/test_lock.py
new file mode 100644 (file)
index 0000000..3fc803a
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestLock(Script):
+    script_name = 'teuthology-lock'
diff --git a/scripts/test/test_ls.py b/scripts/test/test_ls.py
new file mode 100644 (file)
index 0000000..6de10ce
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestLs(Script):
+    script_name = 'teuthology-ls'
diff --git a/scripts/test/test_nuke.py b/scripts/test/test_nuke.py
new file mode 100644 (file)
index 0000000..fa615c4
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestNuke(Script):
+    script_name = 'teuthology-nuke'
diff --git a/scripts/test/test_report.py b/scripts/test/test_report.py
new file mode 100644 (file)
index 0000000..c8065fd
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestReport(Script):
+    script_name = 'teuthology-report'
diff --git a/scripts/test/test_results.py b/scripts/test/test_results.py
new file mode 100644 (file)
index 0000000..a97981c
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestResults(Script):
+    script_name = 'teuthology-results'
diff --git a/scripts/test/test_run.py b/scripts/test/test_run.py
new file mode 100644 (file)
index 0000000..36d42c3
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestRun(Script):
+    script_name = 'teuthology'
diff --git a/scripts/test/test_schedule.py b/scripts/test/test_schedule.py
new file mode 100644 (file)
index 0000000..e89f983
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestSchedule(Script):
+    script_name = 'teuthology-schedule'
diff --git a/scripts/test/test_suite.py b/scripts/test/test_suite.py
new file mode 100644 (file)
index 0000000..062aba4
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestSuite(Script):
+    script_name = 'teuthology-suite'
diff --git a/scripts/test/test_updatekeys.py b/scripts/test/test_updatekeys.py
new file mode 100644 (file)
index 0000000..dabb5cf
--- /dev/null
@@ -0,0 +1,16 @@
+from script import Script
+import subprocess
+from pytest import raises
+
+
+class TestUpdatekeys(Script):
+    script_name = 'teuthology-updatekeys'
+
+    def test_all_and_targets(self):
+        args = (self.script_name, '-a', '-t', 'foo')
+        with raises(subprocess.CalledProcessError):
+            subprocess.check_call(args)
+
+    def test_no_args(self):
+        with raises(subprocess.CalledProcessError):
+            subprocess.check_call(self.script_name)
diff --git a/scripts/test/test_worker.py b/scripts/test/test_worker.py
new file mode 100644 (file)
index 0000000..8e76c43
--- /dev/null
@@ -0,0 +1,5 @@
+from script import Script
+
+
+class TestWorker(Script):
+    script_name = 'teuthology-worker'
diff --git a/tox.ini b/tox.ini
index f9ea1ce5d167a96492317a5cc7eb7f070e39b716..4c97fcb166590b077bc576486aa082b7bd12df94 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -10,9 +10,9 @@ deps=
   fudge
   nose
 
-commands=py.test -v {posargs:teuthology}
+commands=py.test -v {posargs:teuthology scripts}
 
 [testenv:flake8]
 deps=
   flake8
-commands=flake8 --select=F {posargs:teuthology}
+commands=flake8 --select=F {posargs:teuthology scripts}