Skip to content

Commit

Permalink
Fix sentence lookup for new term.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Dec 2, 2023
1 parent 949f8b1 commit ac8364e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lute/term/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def _get_references(self, term):
) pc ON pc.TxBkID = texts.TxBkID
WHERE TxReadDate IS NOT NULL
AND LOWER(SeText) LIKE :pattern
AND BkLgID = {term.language_id}
AND BkLgID = {term.language.id}
LIMIT 20
"""
)
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/term/test_Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,22 @@ def test_get_references_only_includes_refs_in_same_language(spanish, english, re
assert "<b>Tengo</b> un gato." in sentences
assert "No <b>tengo</b> un perro." in sentences
assert "<b>Tengo</b> in english." not in sentences


@pytest.mark.sentences
def test_get_references_new_term(spanish, repo):
"Check references with parents and children."
text = make_text("hola", "Tengo un gato.", spanish)
text.read_date = datetime.now()
db.session.add(text)

tengo = Term()
tengo.language_id = spanish.id
tengo.text = "tengo"

refs = repo.find_references(tengo)
assert full_refs_to_string(refs) == {
"term": ["hola (1/1), <b>Tengo</b> un gato."],
"children": [],
"parents": [],
}, "term tengo"

0 comments on commit ac8364e

Please sign in to comment.