def test_read_all(self): t1 = interface.create(task.Task(desc='test_read_all_1')) t2 = interface.create(task.Task(desc='test_read_all_2')) ts = (interface.read_all() .subscribe_on(rx.concurrency.ThreadPoolScheduler()) .to_list() .to_blocking().first()) self.assertEqual(t1, 1) self.assertEqual(t2, 2) self.assertEqual(ts[0].desc, 'test_read_all_1') self.assertEqual(ts[1].desc, 'test_read_all_2')
def quick_create(tid_buffer, worker=None, state=None): if worker is None: worker = task.Worker.NoAction if state is None: state = task.State.Pending task_prot = task.Task(desc='test', state=state, worker=worker) tid = interface.create(task_prot) t = interface.read(tid) tid_buffer.append(tid) return t
def test_update(self): desc0 = 'test_update' desc1 = 'test_update_modified' tid = interface.create(task.Task(desc=desc0)) tr = interface.read(tid) self.assertEqual(tr.desc, desc0) tr.desc = desc1 interface.update(tr) tr2 = interface.read(tid) self.assertEqual(tr2.desc, desc1)
def quick_create(tid_buffer, state, wks=None): if wks is None: wks = task.Worker.NoAction tid = interface.create(task.Task(state=state, worker=wks)) tid_buffer.append(tid) return tid
def quick_command(command): from fs.tempfs import TempFS with TempFS(auto_clean=False) as t: t = creators.task_command(command, workdir=t.getsyspath('.')) interface.create(t)
def test_delete(self): tid = interface.create(task.Task()) interface.read(tid) interface.delete(tid) with self.assertRaises(TaskNotFoundError): interface.read(tid)
def test_complete(self): tid = interface.create(task.Task()) interface.mark_complete(interface.read(tid)) self.assertEqual(interface.read(tid).state, task.State.Complete)
def test_start(self): tid = interface.create(task.Task()) interface.mark_start(interface.read(tid)) self.assertEqual(interface.read(tid).state, task.State.Runing)
def test_init_state(self): tid = interface.create(task.Task()) self.assertEqual(interface.read(tid).state, task.State.BeforeSubmit)
def test_read(self): tid = interface.create(task.Task(desc='test_read')) tr = interface.read(tid) self.assertEqual(tr.desc, 'test_read')
def test_create(self): tid = interface.create(task.Task()) self.assertIsInstance(tid, int)