[Zope-CVS] CVS: Packages/JobBoardEx/tests - testJob.py:1.6 testJobList.py:1.8

Steve Alexander steve@cat-box.net
Thu, 13 Jun 2002 16:09:47 -0400


Update of /cvs-repository/Packages/JobBoardEx/tests
In directory cvs.zope.org:/tmp/cvs-serv30241/tests

Modified Files:
	testJob.py testJobList.py 
Log Message:
The JobList is now responsible for the ids of the Jobs it contains.
Jobs no longer know their own ids, but their views use
context/@@object_name as necessary to present the id.

Methods that formerly returned lists of jobs now return lists of jobids.
This avoids the issue of whether jobs returned in lists should be
individually context-wrapped.


=== Packages/JobBoardEx/tests/testJob.py 1.5 => 1.6 ===
     def test_initialization(self):
         job = self.job
-        self.assertEqual(job.id, None)
         self.assertEqual(job.submitter, 'submitter')
         self.assertEqual(job.summary, 'summary')
         self.assertEqual(job.description, 'description')
@@ -24,16 +23,6 @@
     def test_states(self):
         self.job.approve()
         self.assertEqual(self.job.state, JobState.Approved)
-
-    def test_id_assignment(self):
-        job = self.job
-        job.id = "foo"
-        self.assertEqual(job.id, "foo")
-        job.id = "bar"
-        self.assertEqual(job.id, "bar")
-        job.id = None
-        self.assertEqual(job.id, None)
-
 
 def test_suite():
     return unittest.TestSuite((unittest.makeSuite(JobTestCase),))


=== Packages/JobBoardEx/tests/testJobList.py 1.7 => 1.8 ===
     def testBasicQuery(self):
         j1 = Job("foo")
-        self.list.add(j1)
+        id1 = self.list.add(j1)
         l = self.list.query("foo")
-        self.assertEqual(l, [j1])
-        self.list.remove(j1)
+        self.assertEqual(l, [id1])
+        del self.list[id1]
         l = self.list.query("foo")
         self.assertEqual(l, [])
 
@@ -29,9 +29,16 @@
 
     def testLookup(self):
         j1 = Job("foo")
-        self.list.add(j1)
-        self.assertEqual(j1, self.list[j1.id])
-        self.assertRaises(KeyError, self.list.__getitem__, j1.id+1)
+        id1 = self.list.add(j1)
+        self.assertEqual(j1, self.list[id1])
+        self.assertRaises(KeyError,
+                          self.list.__getitem__,
+                          int(id1)+1)  # see JobList.query for
+                                       # why the cast to int
 
 def test_suite():
     return unittest.makeSuite(JobListTests)
+
+
+if __name__ == "__main__":
+    unittest.main(defaultTest='test_suite')