Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/unit/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ async def test_chat_success(client):
assert "uid" in data, "La respuesta debe incluir la clave 'uid'"
assert is_valid_uuid(data["uid"]), f"uid no es un UUID válido: {data['uid']}"
app.dependency_overrides.pop(jw_auth_middleware)


# New tests for downvote endpoint
@pytest.mark.asyncio
async def test_downvote_with_comment(client):
chat_id = str(uuid.uuid4())
payload = {"comment": "Mal intento"}
app.dependency_overrides[jw_auth_middleware] = fake_auth
with patch(
"app.api.v1.endpoints.chat.vote_chat", return_value={"status": "downvoted"}
) as mock_vote:
response = await client.post(f"/downvote/{chat_id}", json=payload)
assert response.status_code == 200
assert response.json() == {"status": "downvoted"}
mock_vote.assert_called_once_with(
chat_id, user_id=fake_auth(), down=True, comment="Mal intento"
)
app.dependency_overrides.pop(jw_auth_middleware)