|
|
|
@@ -1,7 +1,18 @@
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from inse import config
|
|
|
|
|
from inse.projects import eu_cordis_projects_client as eu_cordis_search_client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requires_inse_elasticsearch = pytest.mark.skipif(
|
|
|
|
|
not (
|
|
|
|
|
config.settings.elasticsearch_inse_url
|
|
|
|
|
and config.settings.elasticsearch_inse_api_key
|
|
|
|
|
),
|
|
|
|
|
reason="INSE Elasticsearch is not configured",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
async def test_active_period_filter_matches_projects_overlapping_interval():
|
|
|
|
|
query, _, _ = await eu_cordis_search_client._build_eu_cordis_search_query(
|
|
|
|
@@ -18,6 +29,7 @@ async def test_active_period_filter_matches_projects_overlapping_interval():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_title():
|
|
|
|
|
"""Test searching EU CORDIS projects by title."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -35,6 +47,7 @@ async def test_search_eu_cordis_projects_by_title():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_keywords():
|
|
|
|
|
"""Test searching EU CORDIS projects by keywords."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -51,6 +64,7 @@ async def test_search_eu_cordis_projects_by_keywords():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_framework_programme():
|
|
|
|
|
"""Test filtering EU CORDIS projects by framework programme."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -67,6 +81,7 @@ async def test_search_eu_cordis_projects_by_framework_programme():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_status():
|
|
|
|
|
"""Test filtering EU CORDIS projects by status."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -83,6 +98,7 @@ async def test_search_eu_cordis_projects_by_status():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_funding_years():
|
|
|
|
|
"""Test filtering EU CORDIS projects by funding start years."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -101,6 +117,7 @@ async def test_search_eu_cordis_projects_by_funding_years():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_country():
|
|
|
|
|
"""Test filtering EU CORDIS projects by country."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -120,6 +137,7 @@ async def test_search_eu_cordis_projects_by_country():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_organization_name():
|
|
|
|
|
"""Test filtering EU CORDIS projects by organization name."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -139,6 +157,7 @@ async def test_search_eu_cordis_projects_by_organization_name():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_organization_id():
|
|
|
|
|
"""Test filtering EU CORDIS projects by organization ID."""
|
|
|
|
|
# Use a known organization ID (e.g., Max Planck Society)
|
|
|
|
@@ -160,6 +179,7 @@ async def test_search_eu_cordis_projects_by_organization_id():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_project_type():
|
|
|
|
|
"""Test filtering EU CORDIS projects by project type (FP7, H2020, HEU)."""
|
|
|
|
|
from inse.projects.model import EuCordisProjectType
|
|
|
|
@@ -192,6 +212,7 @@ async def test_search_eu_cordis_projects_by_project_type():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_with_sorting():
|
|
|
|
|
"""Test sorting EU CORDIS projects."""
|
|
|
|
|
# Test ascending sort by title
|
|
|
|
@@ -222,6 +243,7 @@ async def test_search_eu_cordis_projects_with_sorting():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_pagination():
|
|
|
|
|
"""Test pagination of EU CORDIS project search results."""
|
|
|
|
|
# Get first page
|
|
|
|
@@ -251,6 +273,7 @@ async def test_search_eu_cordis_projects_pagination():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_get_enriched_cordis_project_by_id():
|
|
|
|
|
"""Test fetching an enriched EU CORDIS project by ID."""
|
|
|
|
|
# Use a known project ID (e.g., an H2020 project)
|
|
|
|
@@ -269,6 +292,7 @@ async def test_get_enriched_cordis_project_by_id():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_get_enriched_cordis_project_by_id_not_found():
|
|
|
|
|
"""Test fetching a non-existent EU CORDIS project."""
|
|
|
|
|
project = await eu_cordis_search_client.get_enriched_cordis_project_by_id("nonexistent_id")
|
|
|
|
@@ -286,6 +310,7 @@ async def test_get_enriched_cordis_project_by_id_empty():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_get_dois_by_cordis_eu_project_id():
|
|
|
|
|
"""Test retrieving DOIs for a CORDIS EU project."""
|
|
|
|
|
known_id = "101016442" # Example H2020 project ID
|
|
|
|
@@ -295,6 +320,7 @@ async def test_get_dois_by_cordis_eu_project_id():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_get_openalex_authors_for_cordis_project_ids():
|
|
|
|
|
"""Test retrieving OpenAlex authors for CORDIS project IDs."""
|
|
|
|
|
project_ids = ["101016442"] # Example H2020 project ID
|
|
|
|
@@ -312,6 +338,7 @@ async def test_get_openalex_authors_for_cordis_project_ids():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_with_multiple_filters():
|
|
|
|
|
"""Test combining multiple filters in EU CORDIS project search."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -334,6 +361,7 @@ async def test_search_eu_cordis_projects_with_multiple_filters():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_empty_results():
|
|
|
|
|
"""Test search that should return no results."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -347,6 +375,7 @@ async def test_search_eu_cordis_projects_empty_results():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_by_funding_scheme():
|
|
|
|
|
"""Test filtering EU CORDIS projects by funding scheme."""
|
|
|
|
|
res = await eu_cordis_search_client.search_eu_cordis_projects(
|
|
|
|
@@ -363,6 +392,7 @@ async def test_search_eu_cordis_projects_by_funding_scheme():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.anyio
|
|
|
|
|
@requires_inse_elasticsearch
|
|
|
|
|
async def test_search_eu_cordis_projects_with_fuzzy_topic_search():
|
|
|
|
|
"""Test fuzzy search with OpenAlex topic IDs."""
|
|
|
|
|
# This test requires known OpenAlex topic IDs
|
|
|
|
|