Repository: aipotheosis-labs/aci
File: aipolabs/server/tests/routes/apps/test_apps.py (Python)

Code before:
    db_session: Session,
    test_client: TestClient,
    dummy_apps: list[App],
    dummy_project_1: Project,
    dummy_api_key_1: str,
) -> None:
    # Create an app configuration for the first app
    app_config = AppConfiguration(
        project_id=dummy_project_1.id,
        app_id=dummy_apps[0].id,
        security_scheme=SecurityScheme.API_KEY,
        security_config_overrides={},
        enabled=True,
        all_functions_enabled=True,
        enabled_functions=[],
    )
    db_session.add(app_config)
    db_session.commit()

    # Test with configured_only=True
    search_params = {
        "configured_only": True,
        "limit": 100,
        "offset": 0,
    }
    response = test_client.get(
        f"{config.ROUTER_PREFIX_APPS}/search",
        params=search_params,
        headers={"x-api-key": dummy_api_key_1},
    )

    assert response.status_code == status.HTTP_200_OK
    apps = [AppBasic.model_validate(response_app) for response_app in response.json()]
    assert len(apps) == 1  # Should only return the one configured app
    assert apps[0].name == dummy_apps[0].name  # assert that the correct app is returned


def test_search_apps_configured_only_with_none_configured(
    db_session: Session,
    test_client: TestClient,
    dummy_apps: list[App],
    dummy_project_1: Project,
    dummy_api_key_1: str,
) -> None:
    # Test with configured_only=True
    search_params = {
        "configured_only": True,
        "limit": 100,
        "offset": 0,
    }
    response = test_client.get(

Review comment (suggestion):
this test case is probably not necessary as what you are trying to test here is covered by `test_search_apps_configured_only `.
additionally,  the comment doesn't match the logic: `assert len(apps) == 0  # Should only return the one configured app`

Code after:
def test_search_apps_configured_only(
    test_client: TestClient,
    dummy_apps: list[App],
    dummy_google_app_configuration_under_dummy_project_1: AppConfigurationPublic,
    dummy_api_key_1: str,
) -> None:

    # Test with configured_only=True
    search_params = {
        "configured_only": True,
        "limit": 100,
        "offset": 0,
    }
    response = test_client.get(
        f"{config.ROUTER_PREFIX_APPS}/search",
        params=search_params,
        headers={"x-api-key": dummy_api_key_1},
    )

    assert response.status_code == status.HTTP_200_OK
    apps = [AppBasic.model_validate(response_app) for response_app in response.json()]
    assert len(apps) == 1, "Should only return the one configured app"
    assert apps[0].name == dummy_apps[0].name, "Returned app and configured app are not the same"


def test_search_apps_configured_only_with_none_configured(
    db_session: Session,
    test_client: TestClient,
    dummy_apps: list[App],
    dummy_project_1: Project,
    dummy_api_key_1: str,
) -> None:
    search_params = {
        "configured_only": True,
        "limit": 100,
        "offset": 0,
    }
    response = test_client.get(
        f"{config.ROUTER_PREFIX_APPS}/search",
        params=search_params,
        headers={"x-api-key": dummy_api_key_1},
    )
    assert response.status_code == status.HTTP_200_OK
    apps = [AppBasic.model_validate(response_app) for response_app in response.json()]
    assert len(apps) == 0, "Should not return any apps"


def test_search_apps_configured_only_exclude_apps_from_other_projects(
    db_session: Session,
    test_client: TestClient,
    dummy_apps: list[App],