def test_JobNameUniq(self): j = Jobs() # validate job name uniqness j.add(name='j1', exec='/bin/date') self.assertEqual(len(j.jobNames()), 1) self.assertEqual(j.jobNames()[0], 'j1') try: j.add(name='j1', exec='/bin/date') self.fail("Duplicated job names in job list") except InvalidJobDescription: pass try: j.addStd(name='j1', execution={'exec': '/bin/date'}) self.fail("Duplicated job names in job list") except InvalidJobDescription: pass j.remove('j1') j.addStd(name='j1', execution={'exec': '/bin/date'}) self.assertEqual(len(j.jobNames()), 1) self.assertEqual(j.jobNames()[0], 'j1') try: j.add(name='j1', exec='/bin/date') self.fail("Duplicated job names in job list") except InvalidJobDescription: pass
def test_JobValidation(self): j = Jobs() try: j.add(name='j1', args=['/bin/date']) self.fail('Missing exec name accepted') except InvalidJobDescription: pass self.assertEqual(len(j.jobNames()), 0) try: j.addStd(name='j1') self.fail('Missing exec name accepted') except InvalidJobDescription: pass self.assertEqual(len(j.jobNames()), 0) try: j.addStd(execution={'exec': '/bin/date'}) self.fail('Missing job name accepted') except InvalidJobDescription: pass self.assertEqual(len(j.jobNames()), 0)