Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Feb 28, 2024
1 parent ffdf36d commit 9a29ba3
Showing 1 changed file with 19 additions and 58 deletions.
77 changes: 19 additions & 58 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ def test_multilingual(self):
],
)
self.assertEqual(0, result.exit_code)
self.assertIn(
"Anomalie phénotypique", result.stdout, "French label should be present"
)
self.assertIn("Anomalie phénotypique", result.stdout, "French label should be present")

def test_languages(self):
for input_arg in [INPUT_DIR / "hp-international-test.db"]:
Expand Down Expand Up @@ -179,15 +177,9 @@ def test_labels(self):

def test_definitions(self):
for input_arg in [f"sqlite:{TEST_DB}"]:
result = self.runner.invoke(
main, ["-i", str(input_arg), "definitions", ".all"]
)
self.assertIn(
"cytoplasm", result.stdout, "cytoplasm should be defined in .all"
)
self.assertIn(
"IAO:0000078", result.stdout, "IAO:0000078 should be included in .all"
)
result = self.runner.invoke(main, ["-i", str(input_arg), "definitions", ".all"])
self.assertIn("cytoplasm", result.stdout, "cytoplasm should be defined in .all")
self.assertIn("IAO:0000078", result.stdout, "IAO:0000078 should be included in .all")
result = self.runner.invoke(
main,
[
Expand Down Expand Up @@ -246,9 +238,7 @@ def test_obograph_local(self):
inputs = [str(TEST_ONT), f"sqlite:{TEST_DB}"]
for input_arg in inputs:
logging.info(f"INPUT={input_arg}")
self.runner.invoke(
main, ["-i", input_arg, "ancestors", NUCLEUS, "-o", outpath]
)
self.runner.invoke(main, ["-i", input_arg, "ancestors", NUCLEUS, "-o", outpath])
out = self._out(outpath)
assert "GO:0043226" in out
self.runner.invoke(
Expand Down Expand Up @@ -416,9 +406,7 @@ def test_roots_and_leafs(self):
result = self.runner.invoke(main, ["-i", input_arg, "leafs", "-p", "i"])
out = result.stdout
assert NUCLEAR_ENVELOPE in out
result = self.runner.invoke(
main, ["-i", input_arg, "singletons", "-p", "i"]
)
result = self.runner.invoke(main, ["-i", input_arg, "singletons", "-p", "i"])
out = result.stdout
assert NUCLEAR_ENVELOPE not in out

Expand Down Expand Up @@ -480,8 +468,7 @@ def test_obsoletes(self):
This should return
"""
input_args = [
str(INPUT_DIR / f"obsoletion_test.{suffix}")
for suffix in ["obo", "owl", "db"]
str(INPUT_DIR / f"obsoletion_test.{suffix}") for suffix in ["obo", "owl", "db"]
]
cases = [
{
Expand Down Expand Up @@ -620,9 +607,7 @@ def test_dump(self):
if conf_path:
cmd.extend(["-c", conf_path])
result = self.runner.invoke(main, cmd)
self.assertEqual(
0, result.exit_code, f"input={input}, output_format={output_format}"
)
self.assertEqual(0, result.exit_code, f"input={input}, output_format={output_format}")
if output_format == "obojson":
obj: obograph.GraphDocument
obj = json_loader.load(output_path, target_class=obograph.GraphDocument)
Expand Down Expand Up @@ -692,9 +677,7 @@ def test_extract(self):
)
if output_format == "obojson":
obj: obograph.GraphDocument
obj = json_loader.load(
TEST_OUT, target_class=obograph.GraphDocument
)
obj = json_loader.load(TEST_OUT, target_class=obograph.GraphDocument)
g = obj.graphs[0]
nucleus_node = [n for n in g.nodes if n.lbl == "nucleus"][0]
self.assertTrue(nucleus_node is not None)
Expand All @@ -714,9 +697,7 @@ def test_extract(self):
self.assertGreater(len(list(g.triples((None, None, None)))), 0)
elif output_format == "obo":
oi = get_adapter(f"simpleobo:{TEST_OUT}")
self.assertEqual(
"nucleus", oi.label(NUCLEUS), "failed with simpleobo"
)
self.assertEqual("nucleus", oi.label(NUCLEUS), "failed with simpleobo")
oi = get_adapter(f"pronto:{TEST_OUT}")
self.assertEqual("nucleus", oi.label(NUCLEUS), "failed with pronto")
elif output_format == "ofn":
Expand Down Expand Up @@ -747,9 +728,7 @@ def test_taxon_constraints_local(self):
contents = self._out()
self.assertIn("Eukaryota", contents)
if fmt == "yaml":
st = yaml_loader.load(
TEST_OUT, target_class=taxon_constraints.SubjectTerm
)
st = yaml_loader.load(TEST_OUT, target_class=taxon_constraints.SubjectTerm)
only_in = st.only_in[0]
self.assertEqual(NUCLEUS, only_in.subject)
self.assertEqual(EUKARYOTA, only_in.taxon.id)
Expand All @@ -766,9 +745,7 @@ def test_search_help(self):
def test_search_local(self):
for input_arg in [str(TEST_ONT), f"sqlite:{TEST_DB}", TEST_OWL_RDF]:
logging.info(f"INPUT={input_arg}")
result = self.runner.invoke(
main, ["-i", input_arg, "search", "l~nucl", "-o", TEST_OUT]
)
result = self.runner.invoke(main, ["-i", input_arg, "search", "l~nucl", "-o", TEST_OUT])
out = self._out()
err = result.stderr
if result.exit_code != 0:
Expand Down Expand Up @@ -892,9 +869,7 @@ def test_search_local_advanced(self):
logging.info(f"{input_arg} // {t}")
terms, complete, expected, excluded = t
if input_arg in excluded:
logging.info(
f"Skipping {terms} as {input_arg} in Excluded: {excluded}"
)
logging.info(f"Skipping {terms} as {input_arg} in Excluded: {excluded}")
continue
result = self.runner.invoke(
main, ["-i", str(input_arg), "info"] + terms + ["-o", TEST_OUT]
Expand All @@ -918,9 +893,7 @@ def test_search_local_advanced(self):
curies.append(m.group(1))
logging.info(f"SEARCH: {terms} => {curies} // {input_arg}")
if complete:
self.assertCountEqual(
expected, set(curies), f"{input_arg} // {terms}"
)
self.assertCountEqual(expected, set(curies), f"{input_arg} // {terms}")
else:
for e in expected:
self.assertIn(e, curies)
Expand Down Expand Up @@ -951,9 +924,7 @@ def test_search_pronto_obolibrary(self):
self.assertIn(SHAPE, out)
self.assertNotIn("PATO:0002021", out) # conical - matches a synonym
self.assertEqual("", err)
result = self.runner.invoke(
main, ["-i", "prontolib:pato.obo", "search", "shape"] + to_out
)
result = self.runner.invoke(main, ["-i", "prontolib:pato.obo", "search", "shape"] + to_out)
out = self._out()
err = result.stderr
self.assertEqual(0, result.exit_code)
Expand Down Expand Up @@ -1105,9 +1076,7 @@ def test_lexmatch(self):
self.assertIn(intracellular_match, contents)
msdf = parse_sssom_table(outfile)
msd = to_mapping_set_document(msdf)
self.assertEqual(
"http://purl.obolibrary.org/obo/XX_", msd.prefix_map["XX"]
)
self.assertEqual("http://purl.obolibrary.org/obo/XX_", msd.prefix_map["XX"])
cases = [
(nucleus_match, NUCLEUS, SKOS_EXACT_MATCH),
(intracellular_match, INTRACELLULAR, SKOS_CLOSE_MATCH),
Expand All @@ -1120,9 +1089,7 @@ def test_lexmatch(self):
cases.remove(tpl)
elif tpl2 in cases:
cases.remove(tpl2)
self.assertEqual(
0, len(cases), f"Cases not found: {cases} for {input_arg}"
)
self.assertEqual(0, len(cases), f"Cases not found: {cases} for {input_arg}")
self.assertEqual("", err)

def test_lexmatch_owl(self):
Expand Down Expand Up @@ -1225,16 +1192,10 @@ def test_diffs(self):
self.assertEqual(0, result.exit_code)
changes = list(parse_kgcl_files([outfile]))
self.assertTrue(
any(
c.about_node == "GO:0033673"
for c in changes
if isinstance(c, NodeChange)
)
any(c.about_node == "GO:0033673" for c in changes if isinstance(c, NodeChange))
)
catalytic_activity_changed = any(
c.about_node == CATALYTIC_ACTIVITY
for c in changes
if isinstance(c, NodeChange)
c.about_node == CATALYTIC_ACTIVITY for c in changes if isinstance(c, NodeChange)
)

self.assertTrue(catalytic_activity_changed)
Expand Down

0 comments on commit 9a29ba3

Please sign in to comment.