import asyncio from typing import Callable import pandas as pd import pytest from src.backend.logic.look_data import look_data from tests_backend.conftest import TEST_LABEL_ID LOOK_DATA_FETCH_FUNCTIONS = [ look_data.fetch_sr, look_data.fetch_sr_ugc1, look_data.fetch_sr_ugc2, look_data.fetch_sr_ugc3, look_data.fetch_mv, look_data.fetch_at, ] @pytest.mark.asyncio @pytest.mark.slow async def test_fetch_functions(): """Real integration test for individual fetch functions. Uses concurrency to speed up the test. """ semaphore = asyncio.Semaphore(5) async def worker(func: Callable, *args, **kwargs): async with semaphore: return await func(*args, **kwargs) result_dfs = await asyncio.gather( *[worker(func, TEST_LABEL_ID) for func in LOOK_DATA_FETCH_FUNCTIONS] ) for df in result_dfs: assert isinstance(df, pd.DataFrame) assert len(df), f"Expected non-empty DataFrame for label ID {TEST_LABEL_ID}."