fix: resolve bugs 01 through 08 and set Ollama TTL to 1h

This commit is contained in:
2026-10-07 19:19:49 +03:00
parent a01bf64445
commit 9bbc9473de
14 changed files with 368 additions and 110 deletions
+50
View File
@@ -2497,6 +2497,56 @@ def test_lessons_debrief_and_history():
assert last_session["errors_count"] == 2
def test_reverse_dictionary_lookup():
"""
BUG-06 regression test: Searching Russian words should perform reverse lookup,
returning the corresponding English term, phonetics, and Russian meaning.
"""
from app.auth import _login_failures
_login_failures.clear()
login_resp = client.post("/api/login", json={"username": "testadmin", "password": "testpass12345"})
assert login_resp.status_code == 200
token = login_resp.json()["token"]
headers = {"Authorization": f"Bearer {token}"}
resp = client.get("/api/lookup?q=собака", headers=headers)
assert resp.status_code == 200
data = resp.json()
assert data["is_reverse"] is True
assert data["term"].lower() == "dog"
assert "собака" in data["translation"].lower()
assert data["phonetic"] != ""
def test_wikipedia_parsoid_html_cleaning():
"""
BUG-05 regression test: Wikipedia Parsoid HTML containing data-mw attributes with
embedded <ref> and literal '>' chars should be cleanly stripped without leaking into text.
"""
from app.reader import clean_wiki_html
sample_html = (
'<body>'
'<span class="mw-empty-elt" about="#mwt1" typeof="mw:Transclusion" '
'data-mw=\'{"parts":[{"template":{"target":{"wt":"Infobox"},"params":{"title":{"wt":"Test<ref>RefText</ref>"}}}]}\'>'
'</span>'
'<p>Linux is a Unix-like operating system.</p>'
'<table style="font-family:\'Times New Roman\', serif;"><tr><td>Clean Cell</td></tr></table>'
'</body>'
)
chapters, cover, words = clean_wiki_html(sample_html, "Test Article")
assert len(chapters) >= 1
content = chapters[0]["content"]
assert "data-mw" not in content
assert "{" not in content
assert "Infobox" not in content
assert "RefText" not in content
assert "Linux is a Unix-like operating system." in content
assert "Times New Roman" not in content # stripped cleanly from table
assert "Clean Cell" in content