def test_merge_1 (self) : myTime = Date(time = None, day = 0, month = 0, year = 0, misc = None) myTime.put() myLoc = Location(city = None, region = None, country = None, missing = None) myLoc.put() myHuman = HumanImpact(deaths = 0, displaced = 0, injured = 0, missing = 0, misc = None) myHuman.put() myEconomic = EconomicImpact(amount = 0, currency = None, misc = None) myEconomic.put() myImpact = Impact(human = myHuman, economic = myEconomic) myImpact.put() myInfo = CrisisInfo(history = None, help = None, resources = None, type_ = None, time = myTime, loc = myLoc, impact = myImpact ) myInfo.put() myLink = Link(site = None, title = None, url = "https://www.google.com", #TODO description = None) myLink.put() myReference = Reference(primaryimage = myLink.key()) myReference.images.append(myLink.key()) myReference.videos.append(myLink.key()) myReference.socials.append(myLink.key()) myReference.exts.append(myLink.key()) myReference.put() entity = Crisis(key_name = "Libyan_Civil_War", idref = "Libyan_Civil_War", name = "Libyan Civil War", info = myInfo, ref = myReference, misc = None, relatedOrgs = [], relatedPeople = [] ) tree = ET.ElementTree(file = open("WC2.xml", "r")) root = tree.getroot() crises = root.findall("crisis") for crisis in crises: if crisis.find("name").text == "Libyan Civil War": merge(entity, crisis) self.assert_(entity.info.time.year == 2011)
def test_merge_2 (self) : myMail = FullAddress(address = None, city = None, state = None, country = None, zip_ = None) myMail.put() myContact = ContactInfo(Phone = None, email =None, mail = myMail) myContact.put() myLoc = Location(city = None, region = None, country = None, missing = None) myLoc.put() myInfo = OrgInfo(type_ = None, history = None, contact = myContact, loc = myLoc ) myInfo.put() myLink = Link(site = None, title = None, url = "https://www.google.com", description = None) myLink.put() myReference = Reference(primaryimage = myLink.key()) myReference.images.append(myLink.key()) myReference.videos.append(myLink.key()) myReference.socials.append(myLink.key()) myReference.exts.append(myLink.key()) myReference.put() entity = Organization(key_name = "International_Criminal_Court", idref = "International_Criminal_Court", name = "International Criminal Court", info = myInfo, ref = myReference, misc = None, relatedCrises = [], relatedPeople = [] ) tree = ET.ElementTree(file = open("WC2.xml", "r")) root = tree.getroot() orgs = root.findall("organization") for organization in orgs: if organization.find("name").text == "International Criminal Court": merge(entity, organization) self.assert_(entity.info.loc.city == "Hague")