Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Feb 28, 2024
1 parent 4672d7a commit cbb8475
Show file tree
Hide file tree
Showing 4 changed files with 452 additions and 88 deletions.
17 changes: 9 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SQLAlchemy = ">=1.4.32"
linkml-runtime = ">=1.5.3"
linkml-renderer = ">=0.3.0"
networkx = ">=2.7.1"
sssom = "^0.4.0"
sssom = "^0.4.4"
ratelimit = ">=2.2.1"
appdirs = ">=1.4.4"
semsql = ">=0.3.1"
Expand All @@ -38,6 +38,7 @@ click = "*"
semsimian = "^0.2.1"
urllib3 = {version = "< 2", optional = true}
pydantic = "*"
importlib-resources = ">=6.1.2"

[tool.poetry.dev-dependencies]
pytest = "^7.1.3"
Expand Down
136 changes: 119 additions & 17 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def test_languages(self):
def test_info(self):
for input_arg in [TEST_ONT, f"sqlite:{TEST_DB}", TEST_OWL_RDF]:
result = self.runner.invoke(
main, ["-i", str(input_arg), "info", NUCLEUS, "-o", TEST_OUT, "-D", "x,d"]
main,
["-i", str(input_arg), "info", NUCLEUS, "-o", TEST_OUT, "-D", "x,d"],
)
result.stdout
result.stderr
Expand Down Expand Up @@ -162,12 +163,14 @@ def test_labels(self):
assert "cytoplasm" in result.stdout
assert "IAO:0000078" in result.stdout
result = self.runner.invoke(
main, ["-i", str(input_arg), "labels", ".all", "--if-absent", "present-only"]
main,
["-i", str(input_arg), "labels", ".all", "--if-absent", "present-only"],
)
assert "cytoplasm" in result.stdout
assert "IAO:0000078" not in result.stdout
result = self.runner.invoke(
main, ["-i", str(input_arg), "labels", ".all", "--if-absent", "absent-only"]
main,
["-i", str(input_arg), "labels", ".all", "--if-absent", "absent-only"],
)
assert "cytoplasm" not in result.stdout
assert "IAO:0000078" in result.stdout
Expand All @@ -178,21 +181,48 @@ def test_definitions(self):
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", "--if-absent", "present-only"]
main,
[
"-i",
str(input_arg),
"definitions",
".all",
"--if-absent",
"present-only",
],
)
self.assertIn(
"cytoplasm", result.stdout, "cytoplasm should be included with present-only query"
"cytoplasm",
result.stdout,
"cytoplasm should be included with present-only query",
)
self.assertNotIn("IAO:0000078", result.stdout)
result = self.runner.invoke(
main, ["-i", str(input_arg), "definitions", ".all", "--if-absent", "absent-only"]
main,
[
"-i",
str(input_arg),
"definitions",
".all",
"--if-absent",
"absent-only",
],
)
self.assertNotIn(
"cytoplasm", result.stdout, "cytoplasm should be excluded with absent-only query"
"cytoplasm",
result.stdout,
"cytoplasm should be excluded with absent-only query",
)
self.assertIn("IAO:0000078", result.stdout)
result = self.runner.invoke(
main, ["-i", str(input_arg), "definitions", "--additional-metadata", "cytoplasm"]
main,
[
"-i",
str(input_arg),
"definitions",
"--additional-metadata",
"cytoplasm",
],
)
self.assertIn(
"ISBN:0198547684",
Expand All @@ -212,13 +242,33 @@ def test_obograph_local(self):
out = self._out(outpath)
assert "GO:0043226" in out
self.runner.invoke(
main, ["-i", input_arg, "ancestors", "-p", "i", "plasma membrane", "-o", outpath]
main,
[
"-i",
input_arg,
"ancestors",
"-p",
"i",
"plasma membrane",
"-o",
outpath,
],
)
out = self._out(outpath)
assert "GO:0016020" in out
assert "GO:0043226" not in out
self.runner.invoke(
main, ["-i", input_arg, "descendants", "-p", "i", "GO:0016020", "-o", outpath]
main,
[
"-i",
input_arg,
"descendants",
"-p",
"i",
"GO:0016020",
"-o",
outpath,
],
)
out = self._out(outpath)
# TODO:
Expand Down Expand Up @@ -397,7 +447,11 @@ def test_tree(self):
[NUCLEUS, IMBO],
[CELLULAR_COMPONENT, CELL],
),
(["-p", "i,p", CYTOPLASM, "--down"], [CYTOPLASM, VACUOLE, "GO:0110165"], []),
(
["-p", "i,p", CYTOPLASM, "--down"],
[CYTOPLASM, VACUOLE, "GO:0110165"],
[],
),
]
for args, expected_in, expected_not_in in cases:
result = self.runner.invoke(main, ["-i", input_arg, "tree", *args])
Expand Down Expand Up @@ -427,7 +481,14 @@ def test_obsoletes(self):
for input_arg in input_args:
result = self.runner.invoke(
main,
["-i", input_arg, "obsoletes", "-o", TEST_OUT, "--show-migration-relationships"],
[
"-i",
input_arg,
"obsoletes",
"-o",
TEST_OUT,
"--show-migration-relationships",
],
)
self.assertEqual(0, result.exit_code)
with open(TEST_OUT) as file:
Expand All @@ -440,7 +501,17 @@ def test_obsoletes(self):

def test_mappings_local(self):
result = self.runner.invoke(
main, ["-i", str(TEST_ONT), "mappings", "GO:0016740", "-o", TEST_OUT, "-O", "csv"]
main,
[
"-i",
str(TEST_ONT),
"mappings",
"GO:0016740",
"-o",
TEST_OUT,
"-O",
"csv",
],
)
self.assertEqual(0, result.exit_code)
out = self._out()
Expand Down Expand Up @@ -588,7 +659,15 @@ def test_extract(self):
for dangling in [True, False]:
logging.info(f"input={input}, output_format={output_format}")
query = [".desc//p=i", IMBO, ".anc//p=i", IMBO]
cmd = ["-i", str(input), "extract", "-o", TEST_OUT, "-O", output_format] + query
cmd = [
"-i",
str(input),
"extract",
"-o",
TEST_OUT,
"-O",
output_format,
] + query
# print(cmd)
if dangling:
cmd += ["--dangling"]
Expand Down Expand Up @@ -634,7 +713,16 @@ def test_taxon_constraints_local(self):
for fmt in ["yaml", "csv", "html"]:
result = self.runner.invoke(
main,
["-i", str(input_arg), "taxon-constraints", NUCLEUS, "-o", TEST_OUT, "-O", fmt],
[
"-i",
str(input_arg),
"taxon-constraints",
NUCLEUS,
"-o",
TEST_OUT,
"-O",
fmt,
],
)
self.assertEqual(0, result.exit_code)
contents = self._out()
Expand Down Expand Up @@ -944,7 +1032,13 @@ def test_lexmatch(self):
nucleus_match = "XX:1"
intracellular_match = "XX:2"
OTHER_ONTOLOGY = f"{INPUT_DIR}/alignment-test.obo"
for input_arg in [TEST_SIMPLE_OBO, TEST_OBOJSON, TEST_OWL_RDF, TEST_ONT, TEST_DB]:
for input_arg in [
TEST_SIMPLE_OBO,
TEST_OBOJSON,
TEST_OWL_RDF,
TEST_ONT,
TEST_DB,
]:
for reversed in [False, True]:
if reversed:
args = [
Expand All @@ -963,7 +1057,14 @@ def test_lexmatch(self):
result = self.runner.invoke(
main,
args
+ ["lexmatch", "-R", RULES_FILE, "-o", outfile, "--no-ensure-strict-prefixes"],
+ [
"lexmatch",
"-R",
RULES_FILE,
"-o",
outfile,
"--no-ensure-strict-prefixes",
],
)
err = result.stderr
self.assertEqual(0, result.exit_code)
Expand Down Expand Up @@ -1096,6 +1197,7 @@ def test_diffs(self):
catalytic_activity_changed = any(
c.about_node == CATALYTIC_ACTIVITY for c in changes if isinstance(c, NodeChange)
)

if simple:
self.assertFalse(catalytic_activity_changed)
else:
Expand Down
Loading

0 comments on commit cbb8475

Please sign in to comment.