From e206f408227a2e5fb6a8171235f21a4e9751c819 Mon Sep 17 00:00:00 2001 From: Kazgatari <56477241+Kazgatari@users.noreply.github.com> Date: Mon, 29 Jun 2026 14:13:58 +0200 Subject: [PATCH] small changes to test and Artifact removal --- service/src/main/inse/funders/logic.py | 1 + service/src/main/inse/funders/test_logic.py | 6 +-- service/src/main/inse/patents/logic.py | 55 ++++++++++----------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/service/src/main/inse/funders/logic.py b/service/src/main/inse/funders/logic.py index 0551b85f..bad9e46e 100644 --- a/service/src/main/inse/funders/logic.py +++ b/service/src/main/inse/funders/logic.py @@ -6,6 +6,7 @@ import logging from typing import Any +from pydantic import ValidationError from ..persons import logic as person_logic from . import model from .elastic_search_client import FundedPublicationsSearchClient diff --git a/service/src/main/inse/funders/test_logic.py b/service/src/main/inse/funders/test_logic.py index 9c95dbd4..52ff0fdb 100644 --- a/service/src/main/inse/funders/test_logic.py +++ b/service/src/main/inse/funders/test_logic.py @@ -1,6 +1,6 @@ import pytest from unittest.mock import AsyncMock, patch -from fastapi import HTTPException +from inse.exceptions import MissingApiKeyError from inse.funders import logic from inse.funders.elastic_search_client import FundedPublicationsSearchClient @@ -340,7 +340,5 @@ async def test_get_funders_by_author_id_maps_missing_api_key_to_service_unavaila client = FundedPublicationsSearchClient(api_key="") - with pytest.raises(HTTPException) as exc: + with pytest.raises(MissingApiKeyError): await logic.get_funders_by_author_id("A5023888391", client=client) - - assert exc.value.status_code == 503 diff --git a/service/src/main/inse/patents/logic.py b/service/src/main/inse/patents/logic.py index 29679f9e..9ff5b490 100644 --- a/service/src/main/inse/patents/logic.py +++ b/service/src/main/inse/patents/logic.py @@ -272,36 +272,35 @@ async def get_all_patents( all_patents_client = AllPatentsSearchClient() ipc_search_client = ipc_client or IpcSearchClient() - try: - if source == "EPO": - epo_data = await all_patents_client.search_epo( - all_patents_client.epo_query(page, size, search, sort_direction) - ) - patents = _parse_epo_hits(epo_data) - total = epo_data.get("hits", {}).get("total", {}).get("value", 0) + if source == "EPO": + epo_data = await all_patents_client.search_epo( + all_patents_client.epo_query(page, size, search, sort_direction) + ) + patents = _parse_epo_hits(epo_data) + total = epo_data.get("hits", {}).get("total", {}).get("value", 0) - elif source == "USPTO": - uspto_data = await all_patents_client.search_uspto( - all_patents_client.uspto_query(page, size, search, sort_direction) - ) - patents = _parse_uspto_hits(uspto_data) - total = uspto_data.get("hits", {}).get("total", {}).get("value", 0) + elif source == "USPTO": + uspto_data = await all_patents_client.search_uspto( + all_patents_client.uspto_query(page, size, search, sort_direction) + ) + patents = _parse_uspto_hits(uspto_data) + total = uspto_data.get("hits", {}).get("total", {}).get("value", 0) - else: - half = size // 2 - epo_data, uspto_data = await asyncio.gather( - all_patents_client.search_epo( - all_patents_client.epo_query(page, half, search, sort_direction) - ), - all_patents_client.search_uspto( - all_patents_client.uspto_query(page, half, search, sort_direction) - ), - ) - patents = _parse_epo_hits(epo_data) + _parse_uspto_hits(uspto_data) - total = ( - epo_data.get("hits", {}).get("total", {}).get("value", 0) + - uspto_data.get("hits", {}).get("total", {}).get("value", 0) - ) + else: + half = size // 2 + epo_data, uspto_data = await asyncio.gather( + all_patents_client.search_epo( + all_patents_client.epo_query(page, half, search, sort_direction) + ), + all_patents_client.search_uspto( + all_patents_client.uspto_query(page, half, search, sort_direction) + ), + ) + patents = _parse_epo_hits(epo_data) + _parse_uspto_hits(uspto_data) + total = ( + epo_data.get("hits", {}).get("total", {}).get("value", 0) + + uspto_data.get("hits", {}).get("total", {}).get("value", 0) + ) await _enrich_patents_classifications(patents, ipc_search_client)