"""Which meeting a question asks for: a month, the latest one when the question is classified as a work question.""" import pytest from tools.answers.planning.question_catalog import CatalogDecision from tools.answers.planning.question_plan import build_question_plan from tools.knowledge.academic import answer_academic from tools.knowledge.sources import profile_units CATALOG = [{'name': 'Jakub Schwarc', 'kind': 'Person', 'source_document': 'pages/students/2022/jakub_schwarc/README.md'}] @pytest.fixture def data(monkeypatch): monkeypatch.setenv('SEARCH_API_KEY', 'meeting-fixture-only-key') units = profile_units({'title': 'Jakub Schwarc', 'path': CATALOG[0]['source_document'], 'content': '# Diplomová práca 2027\nStretnutie 5.11.2026\nStav:\n- Napísané skripty na vyhodnotenie.\n' 'Úlohy:\n- Spustite experiment na HPC.\nStretnutie 1.10.2026\nStav:\n- Porovnané modely.\n' '# Diplomový projekt 2026\nStretnutie 10.6.2026\nStav:\n- Vyskúšaný starší model.'}, include_records=True) return {'version': 'content-v1', 'index_version': {'version': 'v1'}, 'academic_schema': 1, 'units': units} def route(kind, meeting='none', facets=()): return lambda question: CatalogDecision(type=kind, meeting=meeting, facets=list(facets)) def answer(data, question, plan): rows = [r for r in data['units'] if plan.spec.matches_evidence(r)] return answer_academic(question, data, engine='rag', mode='meeting', plan=plan, units=rows)['answer'] @pytest.mark.parametrize('classify', [None, route('meeting', 'exact')]) def test_a_month_asks_for_the_meetings_of_that_month(data, classify): q = 'Mal Jakub Schwarc stretnutie v novembri 2026?' p = build_question_plan(q, CATALOG, classify=classify) assert not p.clarification and p.spec.intent == 'meeting' and p.spec.meeting.selection == 'all' assert (p.spec.period.start, p.spec.period.end, p.spec.period.field) == ('2026-11-01', '2026-11-30', 'record_date') text = answer(data, q, p) assert '2026-11-05' in text and '2026-10-01' not in text and '2026-06-10' not in text def test_a_month_without_a_meeting_is_said_so_and_no_other_meeting_is_shown(data): q = 'Mal Jakub Schwarc stretnutie v marci 2026?' p = build_question_plan(q, CATALOG) text = answer(data, q, p) assert 'nie je doložený záznam stretnutia' in text and '2026-11-05' not in text @pytest.mark.parametrize('classify', [None, route('work_details', facets=['plans']), route('work_metadata')]) def test_the_latest_meeting_of_a_named_person_is_never_asked_back(data, classify): q = 'A aké úlohy dostal Jakub Schwarc na poslednom stretnutí?' p = build_question_plan(q, CATALOG, classify=classify) assert not p.clarification and p.spec.intent == 'meeting' and p.spec.meeting.selection == 'latest' text = answer(data, q, p) assert 'Spustite experiment na HPC' in text and 'Porovnané modely' not in text def test_a_meeting_without_date_month_or_latest_is_still_asked_for(data): p = build_question_plan('Čo riešil Jakub Schwarc na stretnutí?', CATALOG, classify=route('work_details')) assert p.reason == 'missing_meeting_context'