From 8a6dfc3377409dba5bfec8679272285a7c7153ed Mon Sep 17 00:00:00 2001 From: Harshad Date: Mon, 1 Apr 2024 10:33:08 -0500 Subject: [PATCH] Fixed test (#723) --- src/oaklib/utilities/lexical/synonymizer.py | 3 +++ tests/test_cli.py | 4 ---- tests/test_implementations/test_robot_template.py | 6 ++---- tests/test_utilities/test_synonymizer.py | 2 ++ 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/oaklib/utilities/lexical/synonymizer.py b/src/oaklib/utilities/lexical/synonymizer.py index a8782a61c..0d3bfecd6 100644 --- a/src/oaklib/utilities/lexical/synonymizer.py +++ b/src/oaklib/utilities/lexical/synonymizer.py @@ -2,6 +2,7 @@ from typing import Iterable, Iterator, List, Optional, Tuple from kgcl_schema.datamodel import kgcl +from pronto import Definition from oaklib.datamodels.synonymizer_datamodel import RuleSet, Synonymizer from oaklib.datamodels.vocabulary import ( @@ -69,6 +70,8 @@ def apply_synonymizer_to_terms( if include_all: defn = adapter.definition(curie) if defn: + if isinstance(defn, Definition): + defn = str(defn) tvs.append(("definition", [defn])) for scope_pred, aliases in tvs: if aliases is not None: diff --git a/tests/test_cli.py b/tests/test_cli.py index 8a7eb1b81..58c319c8d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -934,10 +934,6 @@ def test_search_local_advanced(self): logging.error(f"INPUT: {input_arg} code = {result.exit_code}") logging.error(f"OUTPUT={out}") logging.error(f"ERR={err}") - if result.exit_code == 1: - import pdb - - pdb.set_trace() self.assertEqual(0, result.exit_code) logging.info(f"OUTPUT={out}") logging.info(f"ERR={err}") diff --git a/tests/test_implementations/test_robot_template.py b/tests/test_implementations/test_robot_template.py index d30fc9dbc..9e586f912 100644 --- a/tests/test_implementations/test_robot_template.py +++ b/tests/test_implementations/test_robot_template.py @@ -52,7 +52,6 @@ def test_basic_ontology_adapter(adapter): } -@pytest.mark.skip("https://github.com/INCATools/kgcl/issues/64") def test_patcher(adapter): changes = [f"rename {BRAIN_SPECIMEN} from 'brain specimen' to 'brain sample'"] if not isinstance(adapter, PatcherInterface): @@ -65,13 +64,12 @@ def test_patcher(adapter): assert isinstance(change_obj, kgcl.NodeRename) print("NEW:", change_obj.new_value) adapter.apply_patch(change_obj) - # adapter.set_label(BRAIN_SPECIMEN, "FOO") - assert adapter.label(BRAIN_SPECIMEN) == "FOO" + assert adapter.label(BRAIN_SPECIMEN) == "brain sample" if not isinstance(adapter, DumperInterface): raise ValueError("Adapter does not support dumping") adapter.dump(SAVED_TEMPLATES, clean=True) adapter2 = get_adapter(f"robottemplate:{SAVED_TEMPLATES}") - assert adapter2.label(BRAIN_SPECIMEN) == "FOO" + assert adapter2.label(BRAIN_SPECIMEN) == "brain sample" def test_set_label(): diff --git a/tests/test_utilities/test_synonymizer.py b/tests/test_utilities/test_synonymizer.py index 191a9bf37..1fa29bd11 100644 --- a/tests/test_utilities/test_synonymizer.py +++ b/tests/test_utilities/test_synonymizer.py @@ -81,6 +81,7 @@ def test_synonymizer(rule, input, expected): "the plasma membrane and nucleus, but including other subcellular structures.' " "to 'All of the contents of a cell excluding the plasma membrane and " "NUCLEUS, but including other subcellular structures.'" + ) ], ), @@ -114,4 +115,5 @@ def test_syonymizer_on_terms(ruleset, include_all, terms, expected): change_str = render(change) print(change_str) changes_strs.append(change_str) + assert set(changes_strs) == set(expected)