From cbe7d8e5a193590d6af54a8671d5516f1d2d1205 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 9 Oct 2013 16:56:49 -0500 Subject: [PATCH] Add basic tests for scripts Signed-off-by: Zack Cerza --- scripts/test/script.py | 16 ++++++++++++++++ scripts/test/test_coverage.py | 5 +++++ scripts/test/test_lock.py | 5 +++++ scripts/test/test_ls.py | 5 +++++ scripts/test/test_nuke.py | 5 +++++ scripts/test/test_report.py | 5 +++++ scripts/test/test_results.py | 5 +++++ scripts/test/test_run.py | 5 +++++ scripts/test/test_schedule.py | 5 +++++ scripts/test/test_suite.py | 5 +++++ scripts/test/test_updatekeys.py | 16 ++++++++++++++++ scripts/test/test_worker.py | 5 +++++ tox.ini | 4 ++-- 13 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 scripts/test/script.py create mode 100644 scripts/test/test_coverage.py create mode 100644 scripts/test/test_lock.py create mode 100644 scripts/test/test_ls.py create mode 100644 scripts/test/test_nuke.py create mode 100644 scripts/test/test_report.py create mode 100644 scripts/test/test_results.py create mode 100644 scripts/test/test_run.py create mode 100644 scripts/test/test_schedule.py create mode 100644 scripts/test/test_suite.py create mode 100644 scripts/test/test_updatekeys.py create mode 100644 scripts/test/test_worker.py diff --git a/scripts/test/script.py b/scripts/test/script.py new file mode 100644 index 0000000000000..4f5aa7a1628c6 --- /dev/null +++ b/scripts/test/script.py @@ -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 index 0000000000000..a04b9e8167803 --- /dev/null +++ b/scripts/test/test_coverage.py @@ -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 index 0000000000000..3fc803aae66f0 --- /dev/null +++ b/scripts/test/test_lock.py @@ -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 index 0000000000000..6de10ce6c33fe --- /dev/null +++ b/scripts/test/test_ls.py @@ -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 index 0000000000000..fa615c46655e0 --- /dev/null +++ b/scripts/test/test_nuke.py @@ -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 index 0000000000000..c8065fd1f82ca --- /dev/null +++ b/scripts/test/test_report.py @@ -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 index 0000000000000..a97981cb6b4ba --- /dev/null +++ b/scripts/test/test_results.py @@ -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 index 0000000000000..36d42c37d8072 --- /dev/null +++ b/scripts/test/test_run.py @@ -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 index 0000000000000..e89f983a7a6bc --- /dev/null +++ b/scripts/test/test_schedule.py @@ -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 index 0000000000000..062aba470d7b2 --- /dev/null +++ b/scripts/test/test_suite.py @@ -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 index 0000000000000..dabb5cf417c8c --- /dev/null +++ b/scripts/test/test_updatekeys.py @@ -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 index 0000000000000..8e76c43a5c5d2 --- /dev/null +++ b/scripts/test/test_worker.py @@ -0,0 +1,5 @@ +from script import Script + + +class TestWorker(Script): + script_name = 'teuthology-worker' diff --git a/tox.ini b/tox.ini index f9ea1ce5d167a..4c97fcb166590 100644 --- 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} -- 2.39.5