summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Šplíchal <psplicha@redhat.com>2011-11-10 16:18:22 +0100
committerPetr Šplíchal <psplicha@redhat.com>2011-11-10 16:18:22 +0100
commitac2ca76083e1bd0403ce6457d7e2c0ae662e2073 (patch)
tree6651713fbda399e762083d79cc96823951a0975e
parent5721574555aa4125bd690c433ab167e5ea8d7a5b (diff)
downloadpython-nitrate-ac2ca76083e1bd0403ce6457d7e2c0ae662e2073.tar.gz
python-nitrate-ac2ca76083e1bd0403ce6457d7e2c0ae662e2073.tar.xz
python-nitrate-ac2ca76083e1bd0403ce6457d7e2c0ae662e2073.zip
Nitrate: Updating an object should update its containers as well
-rw-r--r--Nitrate.py169
1 files changed, 168 insertions, 1 deletions
diff --git a/Nitrate.py b/Nitrate.py
index 7ea9f0d..ce94fe0 100644
--- a/Nitrate.py
+++ b/Nitrate.py
@@ -74,6 +74,10 @@ data of existing objects to be tested, for example:
version = 6.1
status = ENABLED
+ [testrun]
+ id = 6757
+ summary = Test Run Summary
+
[testcase]
id = 1234
summary = Test case summary
@@ -1708,6 +1712,42 @@ class PlanTags(Container):
self._identifier, listed(tags, quote="'")))
self._server.TestPlan.remove_tag(self.id, list(tags))
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Plan Tags Self Test
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ class _test(unittest.TestCase):
+ def setUp(self):
+ """ Set up test plan from the config """
+ self.testplan = Nitrate()._config.testplan
+
+ def testTagging1(self):
+ """ Untagging a test plan """
+ # Remove tag and check
+ testplan = TestPlan(self.testplan.id)
+ testplan.tags.remove("TestTag")
+ testplan.update()
+ testplan = TestPlan(self.testplan.id)
+ self.assertTrue("TestTag" not in testplan.tags)
+
+ def testTagging2(self):
+ """ Tagging a test plan """
+ # Add tag and check
+ testplan = TestPlan(self.testplan.id)
+ testplan.tags.add("TestTag")
+ testplan.update()
+ testplan = TestPlan(self.testplan.id)
+ self.assertTrue("TestTag" in testplan.tags)
+
+ def testTagging3(self):
+ """ Untagging a test plan """
+ # Remove tag and check
+ testplan = TestPlan(self.testplan.id)
+ testplan.tags.remove("TestTag")
+ testplan.update()
+ testplan = TestPlan(self.testplan.id)
+ self.assertTrue("TestTag" not in testplan.tags)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Run Tags Class
@@ -1736,6 +1776,42 @@ class RunTags(Container):
self._identifier, listed(tags, quote="'")))
self._server.TestRun.remove_tag(self.id, list(tags))
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Run Tags Self Test
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ class _test(unittest.TestCase):
+ def setUp(self):
+ """ Set up test run from the config """
+ self.testrun = Nitrate()._config.testrun
+
+ def testTagging1(self):
+ """ Untagging a test run """
+ # Remove tag and check
+ testrun = TestRun(self.testrun.id)
+ testrun.tags.remove("TestTag")
+ testrun.update()
+ testrun = TestRun(self.testrun.id)
+ self.assertTrue("TestTag" not in testrun.tags)
+
+ def testTagging2(self):
+ """ Tagging a test run """
+ # Add tag and check
+ testrun = TestRun(self.testrun.id)
+ testrun.tags.add("TestTag")
+ testrun.update()
+ testrun = TestRun(self.testrun.id)
+ self.assertTrue("TestTag" not in testrun.tags)
+
+ def testTagging3(self):
+ """ Untagging a test run """
+ # Remove tag and check
+ testrun = TestRun(self.testrun.id)
+ testrun.tags.remove("TestTag")
+ testrun.update()
+ testrun = TestRun(self.testrun.id)
+ self.assertTrue("TestTag" not in testrun.tags)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Case Tags Class
@@ -1764,6 +1840,42 @@ class CaseTags(Container):
self._identifier, listed(tags, quote="'")))
self._server.TestCase.remove_tag(self.id, list(tags))
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Case Tags Self Test
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ class _test(unittest.TestCase):
+ def setUp(self):
+ """ Set up test case from the config """
+ self.testcase = Nitrate()._config.testcase
+
+ def testTagging1(self):
+ """ Untagging a test case """
+ # Remove tag and check
+ testcase = TestCase(self.testcase.id)
+ testcase.tags.remove("TestTag")
+ testcase.update()
+ testcase = TestCase(self.testcase.id)
+ self.assertTrue("TestTag" not in testcase.tags)
+
+ def testTagging2(self):
+ """ Tagging a test case """
+ # Add tag and check
+ testcase = TestCase(self.testcase.id)
+ testcase.tags.add("TestTag")
+ testcase.update()
+ testcase = TestCase(self.testcase.id)
+ self.assertTrue("TestTag" in testcase.tags)
+
+ def testTagging3(self):
+ """ Untagging a test case """
+ # Remove tag and check
+ testcase = TestCase(self.testcase.id)
+ testcase.tags.remove("TestTag")
+ testcase.update()
+ testcase = TestCase(self.testcase.id)
+ self.assertTrue("TestTag" not in testcase.tags)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test Plan Class
@@ -1963,6 +2075,8 @@ class TestPlan(Mutable):
self._parent = TestPlan(testplanhash["parent_id"])
else:
self._parent = None
+
+ # Initialize containers
self._tags = PlanTags(self)
self._testcases = TestCases(self)
@@ -1983,6 +2097,18 @@ class TestPlan(Mutable):
log.debug(pretty(hash))
self._server.TestPlan.update(self.id, hash)
+ def update(self):
+ """ Update self and containers, if modified, to the server """
+
+ # Update containers (if initialized)
+ if self._tags is not NitrateNone:
+ self.tags.update()
+ if self._testcases is not NitrateNone:
+ self.testcases.update()
+
+ # Update self (if modified)
+ Mutable.update(self)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test Plan Self Test
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2275,6 +2401,8 @@ class TestRun(Mutable):
self._tester = User(testrunhash["default_tester_id"])
self._testplan = TestPlan(testrunhash["plan_id"])
self._time = testrunhash["estimated_time"]
+
+ # Initialize containers
self._tags = RunTags(self)
def _update(self):
@@ -2296,6 +2424,16 @@ class TestRun(Mutable):
log.debug(pretty(hash))
self._server.TestRun.update(self.id, hash)
+ def update(self):
+ """ Update self and containers, if modified, to the server """
+
+ # Update containers (if initialized)
+ if self._tags is not NitrateNone:
+ self.tags.update()
+
+ # Update self (if modified)
+ Mutable.update(self)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test Case Class
@@ -2508,13 +2646,15 @@ class TestCase(Mutable):
# XXX self._sortkey = testcasehash["sortkey"]
self._status = CaseStatus(testcasehash["case_status_id"])
self._summary = testcasehash["summary"]
- self._tags = CaseTags(self)
self._time = testcasehash["estimated_time"]
if testcasehash["default_tester_id"] is not None:
self._tester = User(testcasehash["default_tester_id"])
else:
self._tester = None
+
+ # Initialize containers
self._bugs = Bugs(self)
+ self._tags = CaseTags(self)
self._testplans = TestPlans(self)
def _update(self):
@@ -2540,6 +2680,21 @@ class TestCase(Mutable):
log.debug(pretty(hash))
self._server.TestCase.update(self.id, hash)
+ def update(self):
+ """ Update self and containers, if modified, to the server """
+
+ # Update containers (if initialized)
+ if self._bugs is not NitrateNone:
+ self.bugs.update()
+ if self._tags is not NitrateNone:
+ self.tags.update()
+ if self._testplans is not NitrateNone:
+ self.testplans.update()
+
+ # Update self (if modified)
+ Mutable.update(self)
+
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Test Case Self Test
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2760,6 +2915,8 @@ class CaseRun(Mutable):
self._testcase = TestCase(testcasehash=testcasehash)
else:
self._testcase = TestCase(caserunhash["case_id"])
+
+ # Initialize containers
self._bugs = Bugs(self)
def _update(self):
@@ -2780,6 +2937,16 @@ class CaseRun(Mutable):
log.debug(pretty(hash))
self._server.TestCaseRun.update(self.id, hash)
+ def update(self):
+ """ Update self and containers, if modified, to the server """
+
+ # Update containers (if initialized)
+ if self._bugs is not NitrateNone:
+ self.bugs.update()
+
+ # Update self (if modified)
+ Mutable.update(self)
+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Self Test