def _test_wrapper_moi(func): """Submit a function through moi""" try: from moi.job import submit_nouser _, _, ar = submit_nouser(func) except: return ('FAIL', traceback.format_exception(*exc_info())) return _ipy_wait(ar)
def moi_test(**kwargs): """Submit a function via moi""" from moi.job import submit_nouser def inner(a, b, **kwargs): return a + b _, _, ar = submit_nouser(inner, 7, 35) state, result = _ipy_wait(ar) return result
def test_submit_nouser(self): def foo(a, b, c=10, **kwargs): return a + b + c id_, pid_, _ = submit_nouser(foo, 1, 2, c=20) self.test_keys.append(id_) self.test_keys.append(pid_) sleep(1) obs = json.loads(r_client.get(id_)) self.assertEqual(obs['result'], 23) self.assertEqual(obs['status'], 'Success') self.assertNotEqual(obs['date_start'], None) self.assertNotEqual(obs['date_end'], None)
def test_submit_nouser(self): def foo(a, b, c=10, **kwargs): return a+b+c id_, pid_ = submit_nouser(foo, 1, 2, c=20) self.test_keys.append(id_) self.test_keys.append(pid_) sleep(2) obs = json.loads(r_client.get(id_)) self.assertEqual(obs['result'], 23) self.assertEqual(obs['status'], 'Success') self.assertNotEqual(obs['date_start'], None) self.assertNotEqual(obs['date_end'], None)