class SantosTest(unittest.TestCase): def setUp(self): self.taskScheduling = ThreadSchedule(name="task", hour="1") def test_hour(self): print("Teste hour") self.assertEqual(self.taskScheduling.calculateInterval(), 3600) def test_minute(self): print("Teste minute") self.taskScheduling = ThreadSchedule(name="task2", minutes="1") self.assertEqual(self.taskScheduling.calculateInterval(), 60) def test_day_of_week_raise(self): print("Teste day_of_the_week") self.taskScheduling = ThreadSchedule(name="task3", day_of_the_week="Sa") with self.assertRaises(TaskException): self.taskScheduling.calculateInterval() def test_params_not_combined(self): self.taskScheduling = ThreadSchedule(name="task4", seconds="2", hour="2") with self.assertRaises(TaskException): self.taskScheduling.calculateInterval()
time.sleep(10) schedule.pause_job(job_name) print("//a//") def f1(schedule, job_name): time.sleep(20) schedule.resume_job(job_name) print("//b//") def f2(schedule, job_name): time.sleep(25) schedule.remove_job(job_name) print("//c//") print("len: {}".format(len(schedule))) def funcao(a): print(a) schedule = ThreadSchedule() schedule.add_job(funcao, seconds="3", id="func1", kwargs={"a": "a"}) print("len1: {}".format(len(schedule))) schedule.add_job(funcao, seconds="3", id="func2", kwargs={"a": "b"}) print("len2: {}".format(len(schedule))) f(schedule, "func1") f1(schedule, "func1") f2(schedule, "func2")
print("//b//") def f2(schedule, job_name): time.sleep(25) schedule.remove_job(job_name) print("//c//") print("len: {}".format(len(schedule))) def funcao(a): print(a) def func(a): print(a) schedule = ThreadSchedule() schedule.add_job(funcao, seconds="4", id="func1", kwargs={"a": "A"}) print("len1: {}".format(len(schedule))) schedule.add_job(funcao, seconds="3", id="func2", kwargs={"a": "B"}) print("len2: {}".format(len(schedule))) schedule.add_job(func, day_of_the_week='Tu', time_of_the_day="02:16:50", id="func3", kwargs={"a": "Time_of"}) print("len3: {}".format(len(schedule))) if __name__ == '__main__': f(schedule, "func1") f1(schedule, "func1") f2(schedule, "func2")
def setUp(self): self.taskScheduling = ThreadSchedule(name="task", hour="1")
def test_params_not_combined(self): self.taskScheduling = ThreadSchedule(name="task4", seconds="2", hour="2") with self.assertRaises(TaskException): self.taskScheduling.calculateInterval()
def test_day_of_week_raise(self): print("Teste day_of_the_week") self.taskScheduling = ThreadSchedule(name="task3", day_of_the_week="Sa") with self.assertRaises(TaskException): self.taskScheduling.calculateInterval()
def test_minute(self): print("Teste minute") self.taskScheduling = ThreadSchedule(name="task2", minutes="1") self.assertEqual(self.taskScheduling.calculateInterval(), 60)