ref: Add ALL ruff rules for tests (#4183)

Add ALL ruff rules for tests
This commit is contained in:
Christophe Bornet 2024-10-19 22:41:37 +02:00 • committed by GitHub
commit f96f2eaf8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 421 additions and 361 deletions

View file

@ -17,7 +17,10 @@ def test_get_suggestion_message():
# Test case 3: Multiple outdated components
outdated_components = ["component1", "component2", "component3"]
expected_message = "The flow contains 3 outdated components. We recommend updating the following components: component1, component2, component3."
expected_message = (
"The flow contains 3 outdated components. "
"We recommend updating the following components: component1, component2, component3."
)
assert get_suggestion_message(outdated_components) == expected_message

View file

@ -75,7 +75,7 @@ async def test_create_variable__variable_value_cannot_be_empty(client: AsyncClie
@pytest.mark.usefixtures("active_user")
async def test_create_variable__HTTPException(client: AsyncClient, body, logged_in_headers):
async def test_create_variable__httpexception(client: AsyncClient, body, logged_in_headers):
status_code = 418
generic_message = "I'm a teapot"
@ -89,7 +89,7 @@ async def test_create_variable__HTTPException(client: AsyncClient, body, logged_
@pytest.mark.usefixtures("active_user")
async def test_create_variable__Exception(client: AsyncClient, body, logged_in_headers):
async def test_create_variable__exception(client: AsyncClient, body, logged_in_headers):
generic_message = "Generic error message"
with mock.patch("langflow.services.auth.utils.encrypt_api_key") as m:
@ -133,16 +133,10 @@ async def test_read_variables__empty(client: AsyncClient, logged_in_headers):
async def test_read_variables__(client: AsyncClient, logged_in_headers):
generic_message = "Generic error message"
with pytest.raises(Exception) as exc, mock.patch("sqlmodel.Session.exec") as m:
with mock.patch("sqlmodel.Session.exec") as m:
m.side_effect = Exception(generic_message)
response = await client.get("api/v1/variables/", headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
assert generic_message in result["detail"]
assert generic_message in str(exc.value)
with pytest.raises(Exception, match=generic_message):
await client.get("api/v1/variables/", headers=logged_in_headers)
@pytest.mark.usefixtures("active_user")
@ -165,7 +159,7 @@ async def test_update_variable(client: AsyncClient, body, logged_in_headers):
@pytest.mark.usefixtures("active_user")
async def test_update_variable__Exception(client: AsyncClient, body, logged_in_headers):
async def test_update_variable__exception(client: AsyncClient, body, logged_in_headers):
wrong_id = uuid4()
body["id"] = str(wrong_id)
@ -186,7 +180,7 @@ async def test_delete_variable(client: AsyncClient, body, logged_in_headers):
@pytest.mark.usefixtures("active_user")
async def test_delete_variable__Exception(client: AsyncClient, logged_in_headers):
async def test_delete_variable__exception(client: AsyncClient, logged_in_headers):
wrong_id = uuid4()
response = await client.delete(f"api/v1/variables/{wrong_id}", headers=logged_in_headers)