Skip to content

Commit

Permalink
toward fixing has #54
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Aug 12, 2021
1 parent 9f75998 commit 2f15662
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
22 changes: 11 additions & 11 deletions geograpy/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ def __init__(self, name:str, entityName:str, entityPluralName:str, listName:str=
filterInvalidListTypes(bool): True if invalidListTypes should be deleted
debug(boolean): override debug setting when default of config is used via config=None
'''
super(LocationManager, self).__init__(name=name,
entityName=entityName,
entityPluralName=entityPluralName,
listName=listName,
clazz=clazz,
tableName=name,
primaryKey=primaryKey,
config=config,
handleInvalidListTypes=handleInvalidListTypes,
filterInvalidListTypes=filterInvalidListTypes,
debug=debug)
super().__init__(name=name,
entityName=entityName,
entityPluralName=entityPluralName,
listName=listName,
clazz=clazz,
tableName=name,
primaryKey=primaryKey,
config=config,
handleInvalidListTypes=handleInvalidListTypes,
filterInvalidListTypes=filterInvalidListTypes,
debug=debug)
self.balltree = None

def getBallTuple(self, cache:bool=True):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jellyfish
numpy
# Tabular storage e.g. SQL/SPARQL/JSON
# https://pypi.org/project/pylodstorage/
pylodstorage>=0.0.63
pylodstorage>=0.0.66
# Documentation Read the docs Theme
sphinx-rtd-theme
# https://pypi.org/project/scikit-learn/
Expand Down
33 changes: 19 additions & 14 deletions tests/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestLocationHierarchy(unittest.TestCase):

def setUp(self):
self.debug=False
self.locationContext=LocationContext.fromJSONBackup()
#self.locationContext=LocationContext.fromJSONBackup()
pass

def tearDown(self):
Expand Down Expand Up @@ -158,23 +158,28 @@ def testLocationListLoading(self):
]
}
"""
countries = CountryManager().restoreFromJsonStr(samples)
# USA is a country that should always be in the list test if present
us_present = False
for country in countries:
if hasattr(country,'wikidataid'):
if country.wikidataid == "Q30":
us_present = True
break
self.assertTrue(us_present)
cm=CountryManager();
cm.restoreFromJsonStr(samples)
countriesByWikiDataId,_dup=cm.getLookup("wikidataid")
self.assertTrue("Q30" in countriesByWikiDataId)


def testCountryManagerFromWikidata(self):
'''
tests if the CountryManager id correctly loaded from Wikidata query result
'''
return # wikidata query results are unreliable
countryList=CountryManager.fromWikidata()
self.assertTrue(len(countryList.countries)>=190)
# wikidata query results are unreliable
try:
countryManager=CountryManager.fromWikidata()
self.assertTrue(len(countryManager.countries)>=190)
countriesByWikiDataId,duplicates=countryManager.getLookup("wikidataid")
if len(duplicates)>0:
for i,duplicate in enumerate(duplicates):
print(f"{i}:{duplicate}")
self.assertEqual(len(duplicates),0)

except Exception as ex:
print(f"Wikidata test failed {ex}")

def testCityManagerFromJSONBackup(self):
'''
Expand Down Expand Up @@ -238,7 +243,7 @@ def test_RegionManagerFromWikidata(self):
'''
tests the loading of the RegionManager from wikidata query results
'''
return # wikidata query results are unreliable
# wikidata query results are unreliable
regionList = RegionManager.fromWikidata()
#check amount of regions
self.assertTrue(len(regionList.regions)>3500)
Expand Down

0 comments on commit 2f15662

Please sign in to comment.