예제 #1
0
 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')
예제 #2
0
파일: test_task.py 프로젝트: Hong-Xiang/dxl
 def test_to_json(self):
     t = task.Task(
         tid=10,
         desc='test',
         workdir='/tmp/test',
         worker=task.Worker.MultiThreading,
         ttype=task.Type.Regular,
         dependency=[1, 2, 3],
         time_stamp=TaskStamp(create=strp("2017-09-22 12:57:44.036185")),
         data={'sample': 42},
         is_root=True)
     s = t.to_json()
     dct = json.loads(s)
     self.assertEqual(dct['id'], 10)
     self.assertEqual(dct['desc'], 'test')
     self.assertEqual(dct['dependency'], [1, 2, 3])
     self.assertEqual(dct['data'], {'sample': 42})
     self.assertEqual(dct['type'], 'Regular')
     self.assertEqual(dct['workdir'], '/tmp/test')
     self.assertEqual(dct['worker'], 'MultiThreading')
     self.assertEqual(dct['is_root'], True)
     self.assertEqual(dct['time_stamp'], {
         'create': "2017-09-22 12:57:44.036185",
         'start': None,
         'end': None
     })
     self.assertEqual(dct['state'], 'BeforeSubmit')
예제 #3
0
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
예제 #4
0
 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)
예제 #5
0
 def test_add_graph(self):
     tasks = [task.Task() for _ in range(3)]
     g = creators.task_graph(tasks, depens=[None, 0, 1])
     tids = interface.create_graph(g)
     self.assertEqual(len(tids), 3)
     tasks = [interface.read(i) for i in tids]
     tasks_root = [t for t in tasks if t.is_root]
     self.assertEqual(len(tasks_root), 1)
     task2 = tasks_root[0]
     task1 = interface.read(task2.dependency[0])
     task0 = interface.read(task1.dependency[0])
     self.assertEqual({task0.id, task1.id, task2.id}, {1, 2, 3})
예제 #6
0
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
예제 #7
0
파일: test_task.py 프로젝트: Hong-Xiang/dxl
 def test_complete(self):
     t = task.Task(10, 'test', state=task.State.BeforeSubmit)
     self.assertEqual(t.state, task.State.BeforeSubmit)
     t = task.complete(t)
     self.assertEqual(t.state, task.State.Complete)
예제 #8
0
파일: test_task.py 프로젝트: Hong-Xiang/dxl
 def test_start(self):
     t = task.Task(10, 'test', state=task.State.BeforeSubmit)
     self.assertEqual(t.state, task.State.BeforeSubmit)
     t = task.start(t)
     self.assertEqual(t.state, task.State.Runing)
예제 #9
0
 def test_delete(self):
     tid = interface.create(task.Task())
     interface.read(tid)
     interface.delete(tid)
     with self.assertRaises(TaskNotFoundError):
         interface.read(tid)
예제 #10
0
 def test_complete(self):
     tid = interface.create(task.Task())
     interface.mark_complete(interface.read(tid))
     self.assertEqual(interface.read(tid).state, task.State.Complete)
예제 #11
0
 def test_start(self):
     tid = interface.create(task.Task())
     interface.mark_start(interface.read(tid))
     self.assertEqual(interface.read(tid).state, task.State.Runing)
예제 #12
0
 def test_init_state(self):
     tid = interface.create(task.Task())
     self.assertEqual(interface.read(tid).state,
                      task.State.BeforeSubmit)
예제 #13
0
 def test_read(self):
     tid = interface.create(task.Task(desc='test_read'))
     tr = interface.read(tid)
     self.assertEqual(tr.desc, 'test_read')
예제 #14
0
 def test_create(self):
     tid = interface.create(task.Task())
     self.assertIsInstance(tid, int)