def test_server_register_correctly_when_started_already(): reg_file = pj(tmp_dir, "registration.json") oas = OAServerFile("doofus", wdir) oas.start() oas.register(reg_file) res = [exists(reg_file)] reg = get_json(reg_file) for key in ('id', 'url', 'urlping', 'urldelete'): res.append(key in reg['args']) oas.stop() assert all(res)
def test_server_ping(): answer_file = pj(tmp_dir, "answer.json") oas = OAServerFile("doofus", wdir) oas.start() oas.register(answer_file) ping_pth = pj(wdir, get_json(answer_file)['args']['urlping']) remove(answer_file) post_json(ping_pth, dict(url=answer_file)) ans = wait_for_content(answer_file, NB) res = [ans['state'] == 'waiting', ans['id'] == "doofus"] oas.stop() oas.join() assert all(res) assert not exists(ping_pth)
def test_server_do_not_react_to_unknown_files(): answer_file = pj(tmp_dir, "answer.json") oas = OAServerFile("doofus", wdir) oas.start() oas.register(answer_file) post_json(pj(wdir, "takapouet.cmd"), dict(a=1)) ping_pth = pj(wdir, get_json(answer_file)['args']['urlping']) remove(answer_file) post_json(ping_pth, dict(url=answer_file)) ans = wait_for_content(answer_file, NB) res = [ans['state'] == 'waiting', ans['id'] == "doofus"] oas.stop() oas.join() assert all(res)
def test_server_compute(): answer_file = pj(tmp_dir, "answer.json") oas = OAServerFile("doofus", wdir) oas.start() oas.register(answer_file) cpt_pth = pj(wdir, get_json(answer_file)['args']['url']) remove(answer_file) post_json(cpt_pth, dict(workflow="pycode:def main(a): return a", urldata="a = 1", urlreturn=answer_file)) ans = wait_for_content(answer_file, NB) res = [ans['result'] == 1, ans['id'] == "doofus"] oas.stop() oas.join() assert all(res) assert not exists(cpt_pth)