fix: restrict council assessment branches by VAK specialty

This commit is contained in:
codex committed 2026-10-12 01:39:44 +03:00
1 parent ccebaddfda
commit 3359ea2f86
12 files changed
+150 -33

No files matched your search

+15
View File
@@ -92,6 +92,21 @@ def main():
assert "Без степени" not in page.content() and "Только звание" not in page.content()
expect(page.locator("#council-date")).to_have_count(0)
assert "Монографии" not in page.content()
branches = page.locator('#council-branch')
specialty = page.locator('#council-specialty')
expect(branches.locator('option')).to_have_count(2)
specialty.select_option('1.1.2')
expect(branches.locator('option')).to_have_count(1)
expect(branches).to_have_value('физико-математические')
specialty.select_option('2.3.2')
expect(branches.locator('option')).to_have_count(1)
expect(branches).to_have_value('технические')
specialty.select_option('1.2.2')
expect(branches.locator('option')).to_have_count(2)
branches.select_option('физико-математические')
specialty.select_option('')
expect(branches).to_have_value('физико-математические')
branches.select_option('технические')
page.get_by_role("button", name="Применить", exact=True).click()
expect(page.get_by_role("link", name="Вход в систему")).to_be_visible()
page.get_by_role("link", name="Далее").click()
+1 -1
View File
@@ -18,7 +18,7 @@ def test_health_returns_versions():
response = TestClient(app).get("/api/health")
assert response.status_code == 200
assert response.json()["backend_version"] == "1.2.1"
assert response.json()["backend_version"] == "1.2.2"
def test_api_employees_and_stats_require_admin_session():
+4 -2
View File
@@ -223,7 +223,7 @@ def test_public_page_data_minimization_and_safe_links(db_session, export):
assert "javascript:" not in fragment.text and "private@example.org" not in fragment.text
assert "javascript:" not in response.text and "private@example.org" not in response.text
assert "/admin/employees/" not in response.text and "/admin/logout" not in response.text
assert "Backend 1.2.1 · Frontend 1.2.1" in response.text
assert "Backend 1.2.2 · Frontend 1.2.2" in response.text
assert "Вход в систему" in response.text
assert client.get("/admin/directory", follow_redirects=False).status_code in (302, 303, 401, 403)
assert "Сотрудники не найдены" in client.get("/admin/council?q=missing").text
@@ -501,7 +501,9 @@ def test_specialty_page_pagination_search_and_export_agree(db_session, export):
client = TestClient(app)
response = client.get("/admin/council?specialty=1.2.2&sort=full_name&direction=asc")
assert response.status_code == 200
assert '<option value="1.2.2" selected>' in response.text
from bs4 import BeautifulSoup
selected = BeautifulSoup(response.text, "html.parser").select_one('#council-specialty option[selected]')
assert selected["value"] == "1.2.2"
assert response.text.count('<option value="2.3.5"') == 1
assert "Публикаций по выбранной специальности: 1" in client.get("/admin/council/employees/1/articles?specialty=1.2.2").text
assert "Не подходит" not in response.text
+41 -7
View File
@@ -48,9 +48,14 @@ def work(db, employee, number=0, year=2024, kind="ARTICLE", basis="К1", **proof
"bases": [{**SOURCE, "basis": basis, "applicable_year": year}], **proof_fields}
def result(db, branch="технические", **kwargs):
def result(db, branch="технические", assessment_branch=None, **kwargs):
db.commit()
return council.council_candidates(db, today=date(2026, 10, 8), branch=branch, **kwargs)["candidates"][0]
value = council.council_candidates(db, today=date(2026, 10, 8), branch=branch, **kwargs)["candidates"][0]
if assessment_branch:
return assessment.assess_candidate(value["degree"].split("; "), value["articles"],
assessment.evidence()["employees"]["test"], assessment_branch, "",
date(2022, 1, 1), date(2026, 12, 31))
return value
@pytest.mark.parametrize("branch,rule", assessment.BRANCHES.items())
@@ -61,7 +66,7 @@ def test_each_doctor_threshold_and_monograph_requirement(db_session, proofs, bra
employee = person(db_session, [degree])
records = [work(db_session, employee, n) for n in range(minimum + delta)]
proofs([{**SOURCE, "degree": degree}], records)
value = result(db_session, branch)
value = result(db_session, assessment_branch=branch)
assert value["minimum"] == minimum and value["monograph_minimum"] == mono
assert value["confirmed_count"] == minimum + delta
assert value["assessment_status"].startswith("Соответствует") == (delta >= 0 and not mono)
@@ -102,10 +107,10 @@ def test_monograph_explicit_evidence_and_period_policy(db_session, proofs, branc
records = [work(db_session, employee, n) for n in range(8)]
records.append(work(db_session, employee, 8, kind="BOOK", kind_evidence=SOURCE))
proofs([{**SOURCE, "degree": degree}], records)
assert result(db_session, branch)["monograph_count"] == 0
assert result(db_session, assessment_branch=branch)["monograph_count"] == 0
records[-1]["kind"] = "monograph"
proofs([{**SOURCE, "degree": degree}], records, {"monograph_period": {**SOURCE, "value": "five_years"}})
value = result(db_session, branch)
value = result(db_session, assessment_branch=branch)
assert value["confirmed_count"] == 8 and value["monograph_count"] == 1
assert value["assessment_status"].startswith("Соответствует")
@@ -175,8 +180,7 @@ def test_http_validation_context_and_export_parity(db_session, proofs, monkeypat
assert "council-date" not in page.text and "Монографии" not in page.text
assert "Дата ходатайства" not in page.text
legacy = client.get("/admin/council/export.xlsx?petition_date=2000-01-01&branch=экономические")
legacy_book = load_workbook(BytesIO(legacy.content))
assert dict(legacy_book["Параметры"].values)["Отрасль оценки"] == "экономические"
assert legacy.status_code == 422
finally:
app.dependency_overrides.clear()
@@ -492,3 +496,33 @@ def test_warning_display_does_not_turn_unknown_type_into_confirmed_article(db_se
assert article['display_type'] == 'Статья' and article['types'] == []
assert article['warnings']['type'] and 'не указан тип материала' in article['warnings']['type'][0]
assert not article['confirmed'] and candidate['confirmed_count'] == 0
@pytest.mark.parametrize("specialty,branches", [
("", ["технические", "физико-математические"]),
("1.1.2", ["физико-математические"]),
("2.3.2", ["технические"]),
*[(code, ["технические", "физико-математические"]) for code in
["1.2.2", "1.3.8", "2.2.2", "2.2.13", "2.2.14", "2.2.15", "2.3.1", "2.3.5", "2.3.6", "2.3.7"]],
])
def test_specialty_limits_branch_options_and_rejects_invalid_requests(db_session, proofs, specialty, branches):
from bs4 import BeautifulSoup
employee = person(db_session, ["Доктор технических наук"])
db_session.commit()
app.dependency_overrides[get_db] = lambda: db_session
try:
client = TestClient(app)
for branch in assessment.BRANCHES:
params = {"specialty": specialty, "branch": branch}
page = client.get("/admin/council", params=params)
if branch in branches:
assert page.status_code == 200
options = BeautifulSoup(page.text, "html.parser").select("#council-branch option")
assert [option["value"] for option in options] == branches
assert next(option["value"] for option in options if "selected" in option.attrs) == branch
else:
assert page.status_code == 422
assert client.get("/admin/council/export.xlsx", params=params).status_code == 422
assert client.get(f"/admin/council/employees/{employee.id}/articles", params=params).status_code == 422
finally:
app.dependency_overrides.clear()