def test_behaviour(self): class TestBehaviour(OneShotBehaviour): async def run(self): msg = Message( to="cservice@localhost") # Instantiate the message msg.set_metadata( "performative", "register") # Set the "inform" FIPA performative msg.body = "Hello" # Set the message content await self.send(msg) msg = Message(to="cservice@localhost") msg.set_metadata("performative", "get") msg.body = "Hello" await self.send(msg) res = await self.receive(timeout=10000) msg = Message(to="cservice@localhost") msg.set_metadata("performative", "deregister_service") msg.body = "Hello" await self.send(msg) service = CService() service.start() agent = CJGomasAgent('sender@localhost') agent.start() behav = TestBehaviour() agent.add_behaviour(behav) while not behav.done(): time.sleep(1) service.stop() agent.stop()
def test_setup(self): class TestBehaviour(OneShotBehaviour): async def run(self): res = await self.receive(timeout=10000) msg = Message(to="objective1@localhost") msg.set_metadata("performative", "inform") msg.body = "Hello" await self.send(msg) agent = CJGomasAgent('cmanager@localhost') agent.start() behav = TestBehaviour() agent.add_behaviour(behav) pack = CObjPack("objective1@localhost") pack.start() while not behav.done(): time.sleep(1) agent.stop() pack.stop()
def test_add_service(self): agent = CJGomasAgent("agent@localhost", "agent", 0) agent.start() agent.stop()