From fc134dad8eb0651a749556e64efc910f972af0d9 Mon Sep 17 00:00:00 2001 From: spsaefan <117728614+spsaefan@users.noreply.github.com> Date: Wed, 22 Jul 2026 23:46:23 +0200 Subject: [PATCH] Update DFG project test --- .../src/main/inse/dashboard/test_service.py | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/service/src/main/inse/dashboard/test_service.py b/service/src/main/inse/dashboard/test_service.py index 8244e305..b2bbd0f0 100644 --- a/service/src/main/inse/dashboard/test_service.py +++ b/service/src/main/inse/dashboard/test_service.py @@ -9,6 +9,7 @@ from sqlmodel import Session, SQLModel, create_engine from inse import config from inse.auth.model import AccessToken, Organization, UserRole from inse.dashboard.service import ( + DFG_INSTITUTION_FIELDS, get_dashboard_organization, get_dashboard_statistics, get_top_authors, @@ -230,18 +231,35 @@ async def test_top_authors_maps_works_and_dfg_project_aggregations(): for call in mocked_search.await_args_list if call.kwargs["index"] == ESIndex.DFG_PROJECTS ] - assert len(dfg_project_calls) == 1 assert dfg_project_calls[0].kwargs["body"]["_source"] == [ - "id", - "project_id", - "persons", + "id", + "project_id", + "persons", + *DFG_INSTITUTION_FIELDS, ] - assert dfg_project_calls[0].kwargs["body"]["query"] == { - "nested": { - "path": "persons", - "query": {"terms": {"persons.person_id": [2]}}, - } + + query = dfg_project_calls[0].kwargs["body"]["query"] + + assert query["bool"]["must"][0]["bool"]["minimum_should_match"] == 1 + assert query["bool"]["must"][0]["bool"]["should"][0]["bool"]["should"][0][ + "match" + ] == { + "Antragstellende Institution": { + "query": "Example Org", + "operator": "and", } +} + + assert query["bool"]["must"][1] == { + "nested": { + "path": "persons", + "query": { + "terms": { + "persons.person_id": [2], + } + }, + } +} @pytest.mark.anyio