[Zope-CVS] CVS: Packages/JobBoardEx/tests - testJobList.py:1.4

Jeremy Hylton jeremy@zope.com
Tue, 19 Mar 2002 18:02:09 -0500


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

Modified Files:
	testJobList.py 
Log Message:
Add implementation and test of lookup() method.

Modify Job class in JobList tests to have a state and an id.




=== Packages/JobBoardEx/tests/testJobList.py 1.3 => 1.4 ===
 
 class Job:
-    def __init__(self, state):
+    def __init__(self, id, state):
         self.state = state
+        self.id = id
 
     def getState(self):
         return self.state
 
+    def getId(self):
+        return self.id
+
 class JobListTests(unittest.TestCase):
 
     def setUp(self):
         self.list = JobList()
 
     def testBasicQuery(self):
-        j1 = Job("foo")
+        j1 = Job(1, "foo")
         self.list.add(j1)
         l = self.list.query("foo")
         self.assertEqual(l, [j1])
@@ -29,6 +33,12 @@
     def testInterface(self):
         verifyClass(IJobList, JobList)
         verifyObject(IJobList, self.list)
+
+    def testLookup(self):
+        j1 = Job(1, "foo")
+        self.list.add(j1)
+        self.assertEqual(j1, self.list.lookup(1))
+        self.assertRaises(KeyError, self.list.lookup, 2)
 
 def test_suite():
     return unittest.makeSuite(JobListTests)