Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testSendMsgP2PPY(self):
template = spade.Behaviour.ACLTemplate()
template.setSender(self.Aaid)
t = spade.Behaviour.MessageTemplate(template)
self.b.addBehaviour(p2pRecvMsgBehav("p2ppy"),t)
self.a.addBehaviour(p2pSendMsgBehav("p2ppy"),None)
counter = 0
while self.b.msg == None and counter < 10:
time.sleep(1)
counter += 1
self.assertNotEqual(self.b.msg,None)
self.assertEqual(self.b.msg.getContent(),"testSendMsg")
self.assertEqual(self.b.msg.getSender(), self.Aaid)
self.assertEqual(len(self.b.msg.getReceivers()),1)
self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
self.assertEqual(self.b.msg._attrs["method"],"p2ppy")
def testSendMsg(self):
template = spade.Behaviour.ACLTemplate()
template.setSender(self.Aaid)
t = spade.Behaviour.MessageTemplate(template)
self.b.addBehaviour(RecvMsgBehav(),t)
self.a.addBehaviour(SendMsgBehav(),None)
counter = 0
while self.b.msg == None and counter < 10:
time.sleep(1)
counter += 1
self.assertNotEqual(self.b.msg,None)
self.assertEqual(self.b.msg.getContent(),"testSendMsg")
self.assertEqual(self.b.msg.getSender(), self.Aaid)
self.assertEqual(len(self.b.msg.getReceivers()),1)
self.assertEqual(self.b.msg.getReceivers()[0], self.Baid)
def testSendAndRecvMsg(self):
template = spade.Behaviour.ACLTemplate()
template.setSender(self.Aaid)
t = spade.Behaviour.MessageTemplate(template)
self.b.addBehaviour(AnswerMsgBehav(),t)
template.setSender(self.Baid)
t = spade.Behaviour.MessageTemplate(template)
self.a.addBehaviour(SendAndRecvMsgBehav(),t)
counter = 0
while self.a.msg == None and counter < 20:
time.sleep(1)
counter += 1
self.assertNotEqual(self.a.msg,None)
self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
def testSendAndRecvMsgP2PPY(self):
template = spade.Behaviour.ACLTemplate()
template.setSender(self.Aaid)
t = spade.Behaviour.MessageTemplate(template)
self.b.addBehaviour(p2pAnswerMsgBehav("p2ppy"),t)
template.setSender(self.Baid)
t = spade.Behaviour.MessageTemplate(template)
self.a.addBehaviour(p2pSendAndRecvMsgBehav("p2ppy"),t)
counter = 0
while self.a.msg == None and counter < 20:
time.sleep(1)
counter += 1
self.assertNotEqual(self.a.msg,None)
self.assertEqual(self.a.msg.getContent(),"testSendAndRecvMsg")
self.assertEqual(self.a.msg._attrs["method"],"p2ppy")
template.setOntology("Dalmuti")
template.setPerformative("request")
template.setConversationId("Inicio")
mt = spade.Behaviour.MessageTemplate(template)
# Comportamiento inicial
self.addBehaviour(self.inicioBehav(), mt)
template.setPerformative( "refuse" )
template.setConversationId("FIN")
mt = spade.Behaviour.MessageTemplate(template)
# Comportamiento de cerrar la conexion
self.addBehaviour(self.cerrarBehav(), mt)
template.setPerformative( "inform" )
template.setConversationId("Tirada")
mt = spade.Behaviour.MessageTemplate(template)
# Comportamiento de actualizar la tirada en la mesa
self.addBehaviour(self.tiradaMesaBehav(), mt)
template.setPerformative( "inform" )
template.setConversationId("Carta")
mt = spade.Behaviour.MessageTemplate(template)
# Comportamiento de actualizar la tirada en la mesa
self.addBehaviour(self.recibirCartasBehav(), mt)
template.setPerformative( "request" )
template.setConversationId("Tira")
mt = spade.Behaviour.MessageTemplate(template)
# Comportamiento tirar en nuestro turno
self.addBehaviour(self.tirarBehav(), mt)
template.setPerformative( "inform" )
def _setup(self):
temp = spade.Behaviour.ACLTemplate()
temp.setPerformative("request")
t = spade.Behaviour.MessageTemplate(spade.Behaviour.ACLTemplate())
self.addBehaviour(self.behav(),t)
def partida(self):
#Empieza una partida indefinidamente
template = spade.Behaviour.ACLTemplate()
template.setOntology("Dalmuti")
template.setPerformative("inform")
template.setConversationId("Tiro")
mt = spade.Behaviour.MessageTemplate(template)
self.addBehaviour(self.partidaBehav(), mt)
template.setPerformative("inform")
template.setConversationId("Salgo")
mt = spade.Behaviour.MessageTemplate(template)
# Anotamos los jugadores que van saliendo
self.addBehaviour(self.saliendoBehav(), mt)