Skip to content

Commit

Permalink
Return boolean from unit test instead of raising an exception as expe…
Browse files Browse the repository at this point in the history
…cted by create_db
  • Loading branch information
m-appel committed Aug 21, 2024
1 parent bfb1d44 commit 32afa77
Show file tree
Hide file tree
Showing 39 changed files with 43 additions and 40 deletions.
5 changes: 4 additions & 1 deletion iyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,14 +715,17 @@ def unit_test(self, relation_types):
relation_types should be a list of types for which existence is checked.
"""
logging.info(f'Running existence test for {relation_types}')
passed = True
for relation_type in relation_types:
existenceQuery = f"""MATCH ()-[r:{relation_type}]-()
USING INDEX r:{relation_type}(reference_name)
WHERE r.reference_name = '{self.reference['reference_name']}'
RETURN 0 LIMIT 1"""
result = self.iyp.tx.run(existenceQuery)
if len(list(result)) == 0:
raise RuntimeError(f'Missing data for relation {relation_type}')
passed = False
logging.error(f'Missing data for relation {relation_type}')
return passed

def close(self):
# Commit changes to IYP
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/alice_lg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,4 @@ def run(self) -> None:
self.iyp.batch_add_links('ORIGINATE', originate_rels)

def unit_test(self):
super().unit_test(['MEMBER_OF', 'ORIGINATE', 'MANAGED_BY'])
return super().unit_test(['MEMBER_OF', 'ORIGINATE', 'MANAGED_BY'])
2 changes: 1 addition & 1 deletion iyp/crawlers/apnic/eyeball.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run(self):
self.iyp.batch_add_links('POPULATION', pop_links)

def unit_test(self):
super().unit_test(['POPULATION', 'COUNTRY', 'RANK', 'NAME'])
return super().unit_test(['POPULATION', 'COUNTRY', 'RANK', 'NAME'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/bgpkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ def run(self):
self.iyp.batch_add_links('PEERS_WITH', links)

def unit_test(self):
super().unit_test(['PEERS_WITH'])
return super().unit_test(['PEERS_WITH'])
2 changes: 1 addition & 1 deletion iyp/crawlers/bgpkit/peerstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run(self):
self.iyp.batch_add_links('PEERS_WITH', links)

def unit_test(self):
super().unit_test(['PEERS_WITH'])
return super().unit_test(['PEERS_WITH'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/bgpkit/pfx2asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self):
self.iyp.batch_add_links('ORIGINATE', links)

def unit_test(self):
super().unit_test(['ORIGINATE'])
return super().unit_test(['ORIGINATE'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/bgptools/anycast_prefixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def update(self, res, filename: str):
self.iyp.batch_add_links('CATEGORIZED', links)

def unit_test(self):
super().unit_test(['CATEGORIZED'])
return super().unit_test(['CATEGORIZED'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/bgptools/as_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def run(self):
self.iyp.batch_add_links('CATEGORIZED', tag_links)

def unit_test(self):
super().unit_test(['NAME'])
return super().unit_test(['NAME'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/bgptools/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def run(self):
print(error)

def unit_test(self):
super().unit_test(['CATEGORIZED'])
return super().unit_test(['CATEGORIZED'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/caida/asrank.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run(self):
self.iyp.batch_add_links('RANK', rank_links)

def unit_test(self):
super().unit_test(['NAME', 'COUNTRY', 'RANK'])
return super().unit_test(['NAME', 'COUNTRY', 'RANK'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/caida/ix_asns.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run(self):
self.iyp.batch_add_links('MEMBER_OF', member_links)

def unit_test(self):
super().unit_test(['MEMBER_OF'])
return super().unit_test(['MEMBER_OF'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/caida/ixs.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def run(self):
self.iyp.batch_add_links('MANAGED_BY', prefix_links)

def unit_test(self):
super().unit_test(['EXTERNAL_ID', 'NAME', 'COUNTRY', 'WEBSITE', 'MANAGED_BY'])
return super().unit_test(['EXTERNAL_ID', 'NAME', 'COUNTRY', 'WEBSITE', 'MANAGED_BY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/cisco/umbrella_top1m.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run(self):
self.iyp.batch_add_links('RANK', processed_links)

def unit_test(self):
super().unit_test(['RANK'])
return super().unit_test(['RANK'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/citizenlab/urldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def run(self):
self.iyp.batch_add_links('CATEGORIZED', links)

def unit_test(self):
super().unit_test(['CATEGORIZED'])
return super().unit_test(['CATEGORIZED'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/cloudflare/dns_top_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def compute_link(self, param):
})

def unit_test(self):
super().unit_test(['QUERIED_FROM'])
return super().unit_test(['QUERIED_FROM'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/cloudflare/ranking_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def run(self):
self.iyp.batch_add_links('RANK', domain_links)

def unit_test(self):
super().unit_test(['RANK'])
return super().unit_test(['RANK'])


# Main program
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/cloudflare/top100.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def update(self, entry):
self.iyp.add_links(domain_qid, statements)

def unit_test(self):
super().unit_test(['RANK'])
return super().unit_test(['RANK'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/emileaben/as_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(self):
self.iyp.batch_add_links('NAME', links)

def unit_test(self):
super().unit_test(['NAME'])
return super().unit_test(['NAME'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/iana/root_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run(self):
self.iyp.batch_add_links('MANAGED_BY', managed_by_relationships)

def unit_test(self):
super().unit_test(['RESOLVES_TO', 'MANAGED_BY'])
return super().unit_test(['RESOLVES_TO', 'MANAGED_BY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ihr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ def run(self):
os.remove(local_filename)

def unit_test(self):
super().unit_test(['DEPENDS_ON'])
return super().unit_test(['DEPENDS_ON'])
2 changes: 1 addition & 1 deletion iyp/crawlers/ihr/country_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def run(self):
self.iyp.batch_add_links('RANK', links)

def unit_test(self):
super().unit_test(['RANK', 'COUNTRY'])
return super().unit_test(['RANK', 'COUNTRY'])


# Main program
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ihr/rov.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def run(self):
os.remove(local_filename)

def unit_test(self):
super().unit_test(['ORIGINATE', 'CATEGORIZED', 'DEPENDS_ON', 'COUNTRY'])
return super().unit_test(['ORIGINATE', 'CATEGORIZED', 'DEPENDS_ON', 'COUNTRY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/inetintel/as_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def close(self):
os.rmdir(self.tmpdir)

def unit_test(self):
super().unit_test(['SIBLING_OF'])
return super().unit_test(['SIBLING_OF'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/manrs/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def run(self):
self.iyp.batch_add_links('IMPLEMENT', implement_rels)

def unit_test(self):
super().unit_test(['MEMBER_OF', 'IMPLEMENT', 'COUNTRY'])
return super().unit_test(['MEMBER_OF', 'IMPLEMENT', 'COUNTRY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/nro/delegated_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def run(self):
self.iyp.batch_add_links(label, links)

def unit_test(self):
super().unit_test(['AVAILABLE', 'ASSIGNED', 'RESERVED', 'COUNTRY'])
return super().unit_test(['AVAILABLE', 'ASSIGNED', 'RESERVED', 'COUNTRY'])


def main() -> None:
Expand Down
4 changes: 2 additions & 2 deletions iyp/crawlers/openintel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def run(self):

def unit_test(self):
# use different version depending on infra_ns vs others
super().unit_test(['RESOLVES_TO', 'MANAGED_BY', 'PART_OF'])
return super().unit_test(['RESOLVES_TO', 'MANAGED_BY', 'PART_OF'])


class DnsgraphCrawler(BaseCrawler):
Expand Down Expand Up @@ -388,4 +388,4 @@ def run(self):
self.iyp.batch_add_node_label(ns_id, 'AuthoritativeNameServer')

def unit_test(self):
super().unit_test(['PARENT', 'PART_OF', 'ALIAS_OF', 'MANAGED_BY', 'RESOLVES_TO'])
return super().unit_test(['PARENT', 'PART_OF', 'ALIAS_OF', 'MANAGED_BY', 'RESOLVES_TO'])
2 changes: 1 addition & 1 deletion iyp/crawlers/pch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ def run(self) -> None:
self.cache_handler.clear_cache()

def unit_test(self):
super().unit_test(['ORIGINATE'])
return super().unit_test(['ORIGINATE'])
2 changes: 1 addition & 1 deletion iyp/crawlers/peeringdb/fac.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def run(self):
self.iyp.batch_add_links('MANAGED_BY', org_links)

def unit_test(self):
super().unit_test(['NAME', 'WEBSITE', 'COUNTRY', 'EXTERNAL_ID', 'MANAGED_BY'])
return super().unit_test(['NAME', 'WEBSITE', 'COUNTRY', 'EXTERNAL_ID', 'MANAGED_BY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/peeringdb/ix.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def register_ixs(self):
self.iyp.batch_add_links('NAME', name_links)

def unit_test(self):
super().unit_test(['MANAGED_BY', 'LOCATED_IN', 'COUNTRY', 'WEBSITE', 'EXTERNAL_ID', 'NAME'])
return super().unit_test(['MANAGED_BY', 'LOCATED_IN', 'COUNTRY', 'WEBSITE', 'EXTERNAL_ID', 'NAME'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/peeringdb/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run(self):
self.iyp.batch_add_links('EXTERNAL_ID', orgid_links)

def unit_test(self):
super().unit_test(['NAME', 'WEBSITE', 'COUNTRY', 'EXTERNAL_ID'])
return super().unit_test(['NAME', 'WEBSITE', 'COUNTRY', 'EXTERNAL_ID'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ripe/as_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run(self):
self.iyp.batch_add_links('COUNTRY', country_links)

def unit_test(self):
super().unit_test(['NAME', 'COUNTRY'])
return super().unit_test(['NAME', 'COUNTRY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ripe/atlas_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def run(self):
logging.info('Done.')

def unit_test(self):
super().unit_test(['PART_OF', 'TARGET'])
return super().unit_test(['PART_OF', 'TARGET'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ripe/atlas_probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def run(self):
self.iyp.batch_add_links('COUNTRY', country_links)

def unit_test(self):
super().unit_test(['ASSIGNED', 'LOCATED_IN', 'COUNTRY'])
return super().unit_test(['ASSIGNED', 'LOCATED_IN', 'COUNTRY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/ripe/roa.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run(self):
self.iyp.batch_add_links('ROUTE_ORIGIN_AUTHORIZATION', links)

def unit_test(self):
super().unit_test(['ROUTE_ORIGIN_AUTHORIZATION'])
return super().unit_test(['ROUTE_ORIGIN_AUTHORIZATION'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/simulamet/rirdata_rdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run(self):
self.iyp.batch_add_links('MANAGED_BY', links_managed_by)

def unit_test(self):
super().unit_test(['MANAGED_BY'])
return super().unit_test(['MANAGED_BY'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/stanford/asdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def run(self):
self.iyp.batch_add_links('CATEGORIZED', links)

def unit_test(self):
super().unit_test(['CATEGORIZED'])
return super().unit_test(['CATEGORIZED'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/tranco/top1m.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run(self):
self.iyp.batch_add_links('RANK', links)

def unit_test(self):
super().unit_test(['RANK'])
return super().unit_test(['RANK'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/virginiatech/rovista.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(self):
self.iyp.batch_add_links('CATEGORIZED', links)

def unit_test(self):
super().unit_test(['CATEGORIZED'])
return super().unit_test(['CATEGORIZED'])


def main() -> None:
Expand Down
2 changes: 1 addition & 1 deletion iyp/crawlers/worldbank/country_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def run(self):
self.iyp.batch_add_links('POPULATION', links)

def unit_test(self):
super().unit_test(['POPULATION'])
return super().unit_test(['POPULATION'])


def main() -> None:
Expand Down

0 comments on commit 32afa77

Please sign in to comment.