Honor the parser's education section type in directory training filters
This commit is contained in:
1 parent
3717a00459
commit
c9f92086e5
2 files changed
+15
-1
No files matched your search
@@ -55,7 +55,8 @@ def _has_training(data: dict[str, Any], since_year: int | None) -> bool:
|
||||
section = _as_dict(value)
|
||||
title = str(section.get("title") or "").casefold().strip().rstrip(":")
|
||||
dedicated = title in {_TRAINING_LABEL, "курсы повышения квалификации"}
|
||||
if not dedicated and _TRAINING_LABEL not in (part.strip() for part in title.split("/")):
|
||||
if (section.get("type") != "additional_education" and not dedicated
|
||||
and _TRAINING_LABEL not in (part.strip() for part in title.split("/"))):
|
||||
continue
|
||||
structured_texts = set()
|
||||
for value in _as_list(section.get("year_entries")):
|
||||
|
||||
@@ -113,3 +113,16 @@ def test_training_filter_uses_course_year_and_kind_before_pagination(db_session)
|
||||
assert client.get("/admin/directory?training_since_year=bad").status_code == 422
|
||||
finally:
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("content", "matches"), [
|
||||
("Курс повышения квалификации по Python", True),
|
||||
("Стажировка в университете", False),
|
||||
])
|
||||
def test_short_education_section_title_does_not_hide_course(db_session, content, matches):
|
||||
url = "https://example.test/profile"
|
||||
soup = BeautifulSoup(f"<h2>Дополнительное образование</h2><p>2025. {content}.</p>", "html.parser")
|
||||
db_session.add(Employee(profile_key="training:short", canonical_url=url,
|
||||
current_data={"sections": extract_sections(soup, url)}))
|
||||
db_session.commit()
|
||||
assert list_employees_page(db_session, training_since_year=2024)["total"] == int(matches)
|
||||
Reference in new issue
Block a user