def test_black_box(sock, server, icmd, idir): api = "handle_call" atom = pyerl.mk_atom("process") cmd = pyerl.mk_string(icmd) name = pyerl.mk_string(idir) tup = pyerl.mk_tuple((atom, cmd, name)) pid = pyerl.mk_pid("node", 1, 2, 3) state = pyerl.mk_atom("atom") # passed state to server is irrelevant in this call args = pyerl.mk_list([tup, pid, state]) eterm = pyerl.rpc(sock, server, api, args) return eterm
def test_mk_string(self): eterm = pyerl.mk_string("string") self.assertEqual(eterm.type, pyerl.LIST); self.assertEqual(eterm.type, pyerl.CONS); self.assertEqual(eterm.is_list(), True); self.assertEqual(eterm.is_cons(), True); self.assertEqual(str(eterm), "\"string\"");
def get_status(sock, server, node, uinput): what = uinput[0] api = "handle_call" status= pyerl.mk_atom("status") if what == 'node': value = uinput[-1] val = pyerl.mk_atom(value) elif what == 'guid': value = uinput[-1] val = pyerl.mk_int(int(value)) elif what == 'pid': rnode = uinput[1] # remote node pid = uinput[2] # remote pid nodename = pyerl.mk_atom(rnode) ppid = pyerl.mk_string(pid) val = pyerl.mk_tuple((nodename, ppid)) else: raise Exception('Unknown message: %s' % what) what = pyerl.mk_atom(what) pid = pyerl.mk_pid("node", 1, 2, 3) state = pyerl.mk_atom("atom") # passed state to server is irrelevant in this call tup = pyerl.mk_tuple((status, what, val)) args = pyerl.mk_list([tup, pid, state]) eterm = pyerl.rpc(sock, server, api, args) return eterm
def test_mk_list(self): atom = eterm = pyerl.mk_atom("atom") integer = eterm = pyerl.mk_int(-1) string = eterm = pyerl.mk_string("string") eterm = pyerl.mk_tuple((atom, integer, string)) self.assertEqual(eterm.is_tuple(), True); self.assertEqual(eterm.type, pyerl.TUPLE); self.assertEqual(str(eterm), "{atom, -1, \"string\"}");
def test_mk_list(self): atom = eterm = pyerl.mk_atom("atom") integer = eterm = pyerl.mk_int(-1) string = eterm = pyerl.mk_string("string") eterm = pyerl.mk_list([atom, integer, string]) self.assertEqual(eterm.is_list(), True); self.assertEqual(eterm.is_cons(), True); self.assertEqual(eterm.type, pyerl.LIST); self.assertEqual(str(eterm), "[atom, -1, \"string\"]");