This commit is contained in:
2026-04-24 22:20:15 +03:30
parent f7dc05dc9e
commit 569d520a5c
24 changed files with 687 additions and 152 deletions
+6 -5
View File
@@ -1,9 +1,10 @@
from unittest.mock import patch
from django.test import TestCase
from django.test import TestCase, override_settings
from rest_framework.test import APIClient
@override_settings(ROOT_URLCONF="config.test_urls")
class RagRecommendationApiTests(TestCase):
def setUp(self):
self.client = APIClient()
@@ -21,7 +22,7 @@ class RagRecommendationApiTests(TestCase):
response = self.client.post(
"/api/rag/recommend/irrigation/",
data={
"sensor_uuid": "sensor-123",
"farm_uuid": "sensor-123",
"plant_name": "گوجه‌فرنگی",
"growth_stage": "میوه‌دهی",
"irrigation_method_name": "قطره‌ای",
@@ -32,7 +33,7 @@ class RagRecommendationApiTests(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()["data"]["plan"]["frequencyPerWeek"], 3)
mock_get_irrigation_recommendation.assert_called_once_with(
sensor_uuid="sensor-123",
farm_uuid="sensor-123",
plant_name="گوجه‌فرنگی",
growth_stage="میوه‌دهی",
irrigation_method_name="قطره‌ای",
@@ -52,7 +53,7 @@ class RagRecommendationApiTests(TestCase):
response = self.client.post(
"/api/rag/recommend/fertilization/",
data={
"sensor_uuid": "sensor-456",
"farm_uuid": "sensor-456",
"plant_name": "گندم",
"growth_stage": "رویشی",
},
@@ -62,7 +63,7 @@ class RagRecommendationApiTests(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()["data"]["plan"]["npkRatio"], "20-20-20")
mock_get_fertilization_recommendation.assert_called_once_with(
sensor_uuid="sensor-456",
farm_uuid="sensor-456",
plant_name="گندم",
growth_stage="رویشی",
query=None,
+4 -4
View File
@@ -130,7 +130,7 @@ class RecommendationServiceDefaultsTests(TestCase):
mock_get_chat_client.return_value.chat.completions.create.return_value = mock_response
result = get_irrigation_recommendation(
sensor_uuid=str(self.farm_uuid),
farm_uuid=str(self.farm_uuid),
growth_stage="میوه‌دهی",
)
@@ -176,7 +176,7 @@ class RecommendationServiceDefaultsTests(TestCase):
mock_get_chat_client.return_value.chat.completions.create.return_value = mock_response
result = get_irrigation_recommendation(
sensor_uuid=str(self.farm_uuid),
farm_uuid=str(self.farm_uuid),
growth_stage="میوه‌دهی",
irrigation_method_name="بارانی",
)
@@ -205,7 +205,7 @@ class RecommendationServiceDefaultsTests(TestCase):
mock_get_chat_client.return_value.chat.completions.create.return_value = mock_response
result = get_fertilization_recommendation(
sensor_uuid=str(self.farm_uuid),
farm_uuid=str(self.farm_uuid),
growth_stage="رویشی",
)
@@ -232,7 +232,7 @@ class RecommendationServiceDefaultsTests(TestCase):
mock_get_chat_client.return_value.chat.completions.create.return_value = mock_response
result = get_fertilization_recommendation(
sensor_uuid=str(self.farm_uuid),
farm_uuid=str(self.farm_uuid),
growth_stage="رویشی",
)