diff options
author | Petr Šplíchal <psplicha@redhat.com> | 2011-07-29 10:31:36 +0200 |
---|---|---|
committer | Petr Šplíchal <psplicha@redhat.com> | 2011-07-29 10:31:36 +0200 |
commit | c9efb538c527697c8b5556253b779d4863fa6b75 (patch) | |
tree | f90bf180bdbb80b1595b08359347e019241decb2 | |
parent | ebf83ce0ae0e35b084fb87393bea1b4850c64048 (diff) | |
download | python-nitrate-c9efb538c527697c8b5556253b779d4863fa6b75.tar.gz python-nitrate-c9efb538c527697c8b5556253b779d4863fa6b75.tar.xz python-nitrate-c9efb538c527697c8b5556253b779d4863fa6b75.zip |
Nitrate: Initial self-test suite implementation
-rw-r--r-- | Nitrate.py | 87 |
1 files changed, 62 insertions, 25 deletions
@@ -13,6 +13,7 @@ Nitrate object which checks ~/.nitrate config file for the url: import os import re import sys +import unittest import ConfigParser import logging as log from pprint import pformat as pretty @@ -2396,29 +2397,65 @@ class CaseRun(Mutable): # Self Test # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class testTestCase(unittest.TestCase): + def testCreateInvalid(self): + """ Create a new test case (missing required parameters) """ + self.assertRaises(NitrateError, TestCase, summary="Test case summary") + + def testCreateValid(self): + """ Create a new test case (valid) """ + case = TestCase(summary="Test case summary", + product="Red Hat Enterprise Linux 6", category="Sanity") + self.assertTrue(isinstance(case, TestCase), "Check created instance") + self.assertEqual(case.summary, "Test case summary") + self.assertEqual(case.priority, Priority("P3")) + + def testFetchExisting(self): + """ Fetch an existing test case """ + new = TestCase(summary="Test case summary", + product="Red Hat Enterprise Linux 6", category="Sanity") + case = TestCase(new.id) + self.assertTrue(isinstance(case, TestCase), "Check the instance") + self.assertEqual(case.summary, "Test case summary") + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Main +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + if __name__ == "__main__": - # Display info about the server - print Nitrate() - - # Show test plan summary and list test cases - testplan = TestPlan(289) - print "\n", testplan.synopsis - for testcase in testplan: - print " ", testcase - - # For each test run list test cases with their status - for testrun in testplan.testruns: - print "\n", testrun.synopsis - for caserun in testrun: - print " ", caserun - - # Update test case data / case run status - TestPlan(289).name = "Tessst plan" - TestRun(6757).notes = "Testing notes" - TestCase(46490).script = "/CoreOS/component/example" - CaseRun(525318).status = Status("PASSED") - TestRun(6757).tags.add("TestTag") - TestRun(6757).status = RunStatus("FINISHED") - - # Display info about the server - print "\n", Nitrate() + + # The full self-test against the test server if url provided + if len(sys.argv) == 2 and "http" in sys.argv[1]: + import __main__ + Nitrate._settings = {'url': sys.argv[1] } + suite = unittest.TestLoader().loadTestsFromModule(__main__) + unittest.TextTestRunner(verbosity=3).run(suite) + + # Otherwise just quick check against the default server + else: + # Display info about the server + print Nitrate() + + # Show test plan summary and list test cases + testplan = TestPlan(289) + print "\n", testplan.synopsis + for testcase in testplan: + print " ", testcase + + # For each test run list test cases with their status + for testrun in testplan.testruns: + print "\n", testrun.synopsis + for caserun in testrun: + print " ", caserun + + # Update test case data / case run status + TestPlan(289).name = "Tessst plan" + TestRun(6757).notes = "Testing notes" + TestCase(46490).script = "/CoreOS/component/example" + CaseRun(525318).status = Status("PASSED") + TestRun(6757).tags.add("TestTag") + TestRun(6757).status = RunStatus("FINISHED") + + # Display info about the server + print "\n", Nitrate() |