fixed the RAg in test pipeline issue

This commit is contained in:
belviskhoremk
2026-04-26 18:51:48 +00:00
parent 205d9d7901
commit 97a501097d
14 changed files with 249 additions and 57 deletions

View File

@@ -185,7 +185,7 @@ class TestMarketplaceRating:
assert resp.status_code == 404
def test_rate_chatbot_success(self, client):
bot = {"id": "bot-1", "average_rating": 4.0}
bot = {"id": "bot-1", "average_rating": 4.0, "rating_count": 1}
with patch("app.routers.marketplace.get_supabase") as mock_sb:
mock_sb.return_value = _make_marketplace_sb(chatbot_data=[bot])
resp = client.post(
@@ -195,12 +195,12 @@ class TestMarketplaceRating:
)
assert resp.status_code == 200
body = resp.json()
assert "new_average" in body
assert body["new_average"] == 4.5 # (4.0 + 5) / 2
assert "average_rating" in body
assert body["average_rating"] == 4.5 # (4.0 * 1 + 5) / 2
def test_rate_chatbot_first_rating(self, client):
"""When average_rating is None, should use the submitted rating as both sides."""
bot = {"id": "bot-1", "average_rating": None}
"""When average_rating is None, should use the submitted rating as the new average."""
bot = {"id": "bot-1", "average_rating": None, "rating_count": 0}
with patch("app.routers.marketplace.get_supabase") as mock_sb:
mock_sb.return_value = _make_marketplace_sb(chatbot_data=[bot])
resp = client.post(
@@ -209,4 +209,4 @@ class TestMarketplaceRating:
headers=AUTH,
)
assert resp.status_code == 200
assert resp.json()["new_average"] == 5.0
assert resp.json()["average_rating"] == 5.0