[Zope-CVS] CVS: Packages/JobBoardI18n/tests - __init__.py:1.1 testJob.py:1.1 testJobList.py:1.1
Barry Warsaw
barry@wooz.org
Mon, 17 Jun 2002 19:57:57 -0400
Update of /cvs-repository/Packages/JobBoardI18n/tests
In directory cvs.zope.org:/tmp/cvs-serv18888/tests
Added Files:
__init__.py testJob.py testJobList.py
Log Message:
An internationalized version of the JobBoardEx example.
=== Added File Packages/JobBoardI18n/tests/__init__.py ===
# test package
=== Added File Packages/JobBoardI18n/tests/testJob.py ===
"""
testJob.py
"""
import unittest
from ZopeProducts.JobBoardEx.Job import Job
from ZopeProducts.JobBoardEx.IJob import JobState
class JobTestCase(unittest.TestCase):
def setUp(self):
self.job = Job("submitter", "summary", "description", "contact")
def test_initialization(self):
job = self.job
self.assertEqual(job.submitter, 'submitter')
self.assertEqual(job.summary, 'summary')
self.assertEqual(job.description, 'description')
self.assertEqual(job.contact, 'contact')
self.assertEqual(job.state, JobState.PendingApproval)
def test_states(self):
self.job.approve()
self.assertEqual(self.job.state, JobState.Approved)
def test_suite():
return unittest.TestSuite((unittest.makeSuite(JobTestCase),))
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
=== Added File Packages/JobBoardI18n/tests/testJobList.py ===
import unittest
from ZopeProducts.JobBoardEx.JobList import JobList
from ZopeProducts.JobBoardEx.IJobList import IJobList
from Interface.Verify import verifyClass, verifyObject
class Job:
def __init__(self, state):
self.state = state
class JobListTests(unittest.TestCase):
def setUp(self):
self.list = JobList()
def testBasicQuery(self):
j1 = Job("foo")
id1 = self.list.add(j1)
l = self.list.query("foo")
self.assertEqual(l, [id1])
del self.list[id1]
l = self.list.query("foo")
self.assertEqual(l, [])
def testInterface(self):
verifyClass(IJobList, JobList)
verifyObject(IJobList, self.list)
def testLookup(self):
j1 = Job("foo")
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')