refactor: Replace async_open by anyio.Path methods in tests (#6847)

Replace async_open by anyio.Path methods in tests

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Christophe Bornet 2025-02-27 02:00:39 +01:00 committed by GitHub
commit 5133f1cc19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 22 deletions

View file

@ -1,9 +1,8 @@
import asyncio
import inspect
from pathlib import Path
from typing import Any
from aiofile import async_open
from anyio import Path
from fastapi import status
from httpx import AsyncClient
from langflow.api.v1.schemas import UpdateCustomComponentRequest
@ -36,8 +35,8 @@ async def test_get_config(client: AsyncClient):
async def test_update_component_outputs(client: AsyncClient, logged_in_headers: dict):
path = Path(__file__).parent.parent.parent.parent / "data" / "dynamic_output_component.py"
async with async_open(path, encoding="utf-8") as f:
code = await f.read()
code = await path.read_text(encoding="utf-8")
frontend_node: dict[str, Any] = {"outputs": []}
request = UpdateCustomComponentRequest(
code=code,
@ -69,8 +68,7 @@ async def test_update_component_model_name_options(client: AsyncClient, logged_i
# we are at str/backend/tests/unit/api/v1/test_endpoints.py
# find the file by using the class AgentComponent
agent_component_file = await asyncio.to_thread(inspect.getsourcefile, AgentComponent)
async with async_open(agent_component_file, encoding="utf-8") as f:
code = await f.read()
code = await Path(agent_component_file).read_text(encoding="utf-8")
# Create the request to update the component
request = UpdateCustomComponentRequest(