parent
db2c12183c
commit
3c6ec0cf9e
13 changed files with 94 additions and 63 deletions
|
|
@ -16,7 +16,8 @@ async def body():
|
|||
}
|
||||
|
||||
|
||||
async def test_create_variable(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable(client: AsyncClient, body, logged_in_headers):
|
||||
response = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
result = response.json()
|
||||
|
||||
|
|
@ -28,7 +29,8 @@ async def test_create_variable(client: AsyncClient, body, active_user, logged_in
|
|||
assert body["value"] != result["value"]
|
||||
|
||||
|
||||
async def test_create_variable__variable_name_already_exists(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable__variable_name_already_exists(client: AsyncClient, body, logged_in_headers):
|
||||
await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
|
||||
response = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
|
|
@ -38,9 +40,8 @@ async def test_create_variable__variable_name_already_exists(client: AsyncClient
|
|||
assert "Variable name already exists" in result["detail"]
|
||||
|
||||
|
||||
async def test_create_variable__variable_name_and_value_cannot_be_empty(
|
||||
client: AsyncClient, body, active_user, logged_in_headers
|
||||
):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable__variable_name_and_value_cannot_be_empty(client: AsyncClient, body, logged_in_headers):
|
||||
body["name"] = ""
|
||||
body["value"] = ""
|
||||
|
||||
|
|
@ -51,9 +52,8 @@ async def test_create_variable__variable_name_and_value_cannot_be_empty(
|
|||
assert "Variable name and value cannot be empty" in result["detail"]
|
||||
|
||||
|
||||
async def test_create_variable__variable_name_cannot_be_empty(
|
||||
client: AsyncClient, body, active_user, logged_in_headers
|
||||
):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable__variable_name_cannot_be_empty(client: AsyncClient, body, logged_in_headers):
|
||||
body["name"] = ""
|
||||
|
||||
response = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
|
|
@ -63,9 +63,8 @@ async def test_create_variable__variable_name_cannot_be_empty(
|
|||
assert "Variable name cannot be empty" in result["detail"]
|
||||
|
||||
|
||||
async def test_create_variable__variable_value_cannot_be_empty(
|
||||
client: AsyncClient, body, active_user, logged_in_headers
|
||||
):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable__variable_value_cannot_be_empty(client: AsyncClient, body, logged_in_headers):
|
||||
body["value"] = ""
|
||||
|
||||
response = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
|
|
@ -75,7 +74,8 @@ async def test_create_variable__variable_value_cannot_be_empty(
|
|||
assert "Variable value cannot be empty" in result["detail"]
|
||||
|
||||
|
||||
async def test_create_variable__HTTPException(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_create_variable__HTTPException(client: AsyncClient, body, logged_in_headers):
|
||||
status_code = 418
|
||||
generic_message = "I'm a teapot"
|
||||
|
||||
|
|
@ -88,7 +88,8 @@ async def test_create_variable__HTTPException(client: AsyncClient, body, active_
|
|||
assert generic_message in result["detail"]
|
||||
|
||||
|
||||
async def test_create_variable__Exception(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
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:
|
||||
|
|
@ -100,7 +101,8 @@ async def test_create_variable__Exception(client: AsyncClient, body, active_user
|
|||
assert generic_message in result["detail"]
|
||||
|
||||
|
||||
async def test_read_variables(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_read_variables(client: AsyncClient, body, logged_in_headers):
|
||||
names = ["test_variable1", "test_variable2", "test_variable3"]
|
||||
for name in names:
|
||||
body["name"] = name
|
||||
|
|
@ -113,7 +115,8 @@ async def test_read_variables(client: AsyncClient, body, active_user, logged_in_
|
|||
assert all(name in [r["name"] for r in result] for name in names)
|
||||
|
||||
|
||||
async def test_read_variables__empty(client: AsyncClient, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_read_variables__empty(client: AsyncClient, logged_in_headers):
|
||||
all_variables = await client.get("api/v1/variables/", headers=logged_in_headers)
|
||||
all_variables = all_variables.json()
|
||||
for variable in all_variables:
|
||||
|
|
@ -126,7 +129,8 @@ async def test_read_variables__empty(client: AsyncClient, active_user, logged_in
|
|||
assert [] == result
|
||||
|
||||
|
||||
async def test_read_variables__(client: AsyncClient, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_read_variables__(client: AsyncClient, logged_in_headers):
|
||||
generic_message = "Generic error message"
|
||||
|
||||
with pytest.raises(Exception) as exc:
|
||||
|
|
@ -142,7 +146,8 @@ async def test_read_variables__(client: AsyncClient, active_user, logged_in_head
|
|||
assert generic_message in str(exc.value)
|
||||
|
||||
|
||||
async def test_update_variable(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_update_variable(client: AsyncClient, body, logged_in_headers):
|
||||
saved = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
saved = saved.json()
|
||||
body["id"] = saved.get("id")
|
||||
|
|
@ -160,7 +165,8 @@ async def test_update_variable(client: AsyncClient, body, active_user, logged_in
|
|||
assert saved["default_fields"] != result["default_fields"]
|
||||
|
||||
|
||||
async def test_update_variable__Exception(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_update_variable__Exception(client: AsyncClient, body, logged_in_headers):
|
||||
wrong_id = uuid4()
|
||||
body["id"] = str(wrong_id)
|
||||
|
||||
|
|
@ -171,7 +177,8 @@ async def test_update_variable__Exception(client: AsyncClient, body, active_user
|
|||
assert "Variable not found" in result["detail"]
|
||||
|
||||
|
||||
async def test_delete_variable(client: AsyncClient, body, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
async def test_delete_variable(client: AsyncClient, body, logged_in_headers):
|
||||
response = await client.post("api/v1/variables/", json=body, headers=logged_in_headers)
|
||||
saved = response.json()
|
||||
response = await client.delete(f"api/v1/variables/{saved.get('id')}", headers=logged_in_headers)
|
||||
|
|
@ -179,7 +186,8 @@ async def test_delete_variable(client: AsyncClient, body, active_user, logged_in
|
|||
assert status.HTTP_204_NO_CONTENT == response.status_code
|
||||
|
||||
|
||||
async def test_delete_variable__Exception(client: AsyncClient, active_user, logged_in_headers):
|
||||
@pytest.mark.usefixtures("active_user")
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue