def test_in_ids(self): jobs = Jobs([self.job1, self.job2, self.job3, self.job4, self.job5]) subjobs = jobs.in_ids([1, 2, 5]) self.assertEquals(self.job1, subjobs.get(1)) self.assertEquals(self.job2, subjobs.get(2)) self.assertEquals(self.job5, subjobs.get(3))
def test_get(self): jobs = Jobs([self.job1, self.job2, self.job3, self.job4, self.job5]) self.assertEquals(self.job1, jobs.get(1)) self.assertEquals(self.job2, jobs.get(2)) self.assertEquals(self.job3, jobs.get(3)) self.assertEquals(self.job4, jobs.get(4)) self.assertEquals(self.job5, jobs.get(5))
def test_remove(self): joblist = [self.job1, self.job2, self.job3, self.job4, self.job5] jobs = Jobs(joblist[:]) #remove job1 joblist.remove(self.job1) jobs.remove(self.job1) self.assertEquals(jobs.all(), joblist)
def test_all(self): joblist = [ self.job1, self.job2, self.job3, self.job4, self.job5, self.job6, ] jobs = Jobs(joblist) self.assertEquals(joblist, jobs.all())
def test_merge(self): jobsa = Jobs([self.job1, self.job2, self.job3]) jobsb = Jobs([self.job4, self.job5]) jobsa.merge(jobsb) self.assertEquals(self.job1, jobsa.get(1)) self.assertEquals(self.job2, jobsa.get(2)) self.assertEquals(self.job3, jobsa.get(3)) self.assertEquals(self.job4, jobsa.get(4)) self.assertEquals(self.job5, jobsa.get(5))
def test_iterator(self): joblist = [ self.job1, self.job2, self.job3, self.job4, self.job5, self.job6, ] jobs = Jobs(joblist[:]) for index, job in enumerate(jobs): self.assertEquals(job.line, joblist[index].line)
def test_add(self): # test jobs from constructor jobs = Jobs([self.job1, self.job2, self.job3]) self.assertEquals(len(jobs), 3) # test add method jobs.add(self.job4) jobs.add(self.job5) self.assertEquals(len(jobs), 5) # test adding an invalid job with self.assertRaises(AttributeError): jobs.add('invalidobject') jobs.clear_all()
def test_clear_all(self): jobs = Jobs([self.job1, self.job2, self.job3]) jobs.clear_all() self.assertEquals(len(jobs), 0)