Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def CreateDAD(s=""):
dad = spade.DF.DfAgentDescription()
aid = spade.AID.aid()
aid.setName("aidname"+s)
dad.setAID(aid)
dad.addProtocol("protocol1"+s)
dad.addOntologies("ontology1"+s)
dad.addLanguage("language1"+s)
dad.setLeaseTime(1000)
dad.addScope("scope1"+s)
return dad
def testMatchDAD(self):
dad1 = CreateDAD("a")
dad2 = spade.DF.DfAgentDescription()
aid = spade.AID.aid()
aid.setName("aidnamea")
dad2.setAID(aid)
self.assertEqual(dad1.match(dad2),True)
dad2.addLanguage("language1a")
self.assertEqual(dad1.match(dad2),True)
dad1.addLanguage("language2a")
self.assertEqual(dad1.match(dad2),True)
dad2.addLanguage("language3a")
self.assertEqual(dad1.match(dad2),False)
dad1 = CreateDAD("a")
dad2 = spade.DF.DfAgentDescription()
def EmptySearch_DAD(agent):
dad = spade.DF.DfAgentDescription()
agent.result = agent.searchService(dad)
aid = spade.AID.aid()
aid.setName("aidnamea")
dad2.setAID(aid)
self.assertEqual(dad1.match(dad2),True)
dad2.addLanguage("language1a")
self.assertEqual(dad1.match(dad2),True)
dad1.addLanguage("language2a")
self.assertEqual(dad1.match(dad2),True)
dad2.addLanguage("language3a")
self.assertEqual(dad1.match(dad2),False)
dad1 = CreateDAD("a")
dad2 = spade.DF.DfAgentDescription()
aid = spade.AID.aid()
aid.setName("aidnamea")
dad2.setAID(aid)
sd1 = CreateSD("a")
dad1.addService(sd1)
dad2.addService(sd1)
self.assertEqual(dad1.match(dad2),True)
sd2 = CreateSD("b")
dad2.addService(sd2)
self.assertEqual(dad1.match(dad2),False)
dad1.addService(sd2)
self.assertEqual(dad1.match(dad2),True)
def Search_2_DAD(agent, param):
dad = spade.DF.DfAgentDescription()
sd = spade.DF.ServiceDescription()
sd.setName("unittest_name_1_"+param)
#sd.setType("unittest_type_1")
dad.addService(sd)
sd = spade.DF.ServiceDescription()
sd.setName("unittest_name_2_"+param)
#sd.setType("unittest_type_1")
dad.addService(sd)
dad.setAID(agent.getAID())
agent.result = agent.searchService(dad)