def test_command_SLEEP(): #command.context = {} s = command.factory("SLEEP") s.vm = "vm" s.execute("vm", "protocol", {"ciao":"mondo"}) logging.debug(command.context) assert "ciao" in command.context assert command.context["ciao"] == "mondo" s = command.factory("SET") s.vm = "vm" s.execute( s.vm, {"pippo":"franco", "hello":"world", "number":"123"}) assert "ciao" in command.context assert command.context["ciao"] == "mondo" logging.debug(command.context)
def test_command_SLEEP(): #command.context = {} s = command.factory("SLEEP") s.vm = "vm" s.execute("vm", "protocol", {"ciao": "mondo"}) logging.debug(command.context) assert "ciao" in command.context assert command.context["ciao"] == "mondo" s = command.factory("SET") s.vm = "vm" s.execute(s.vm, {"pippo": "franco", "hello": "world", "number": "123"}) assert "ciao" in command.context assert command.context["ciao"] == "mondo" logging.debug(command.context)
def test_dispatcher(): c = command.factory(["BEGIN", True, ['whatever', 'end']]) agentFiles = "" params = "" update = Procedure("UPDATE", ["REVERT", "START_VM", "RELOG", "STOP_VM"]) dispatch = Procedure("DISPATCH", ["REVERT", "START_VM", ("PUSH", None, agentFiles)]) scout = Procedure("SCOUT", [ ("CALL", None, "dispatch"), ("PUSH", None, agentFiles), ]) assert update assert dispatch assert scout
def test_procedure_insert(): c = command.factory(["BEGIN", True, ['whatever', 'end']]) agentFiles = "" params = "" p1 = Procedure("UPDATE", ["REVERT", "START_VM", "RELOG", "STOP_VM"]) p2 = Procedure("DISPATCH", ["REVERT", "START_VM", ("PUSH", None, agentFiles)]) lp1= len(p1) lp2= len(p2) p1.insert(p2) assert p1 assert p2 assert len(p1) == lp1 + lp2