cleans up tests

This commit is contained in:
2025-08-11 20:07:59 -07:00
parent cc1523cbb2
commit de7e03f8e7
3 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1 @@
Fixed failing integration test in tests/integration/test_ai_rule_endpoints.py::TestAIRuleEndpoints::test_assess_rule_success. The issue was with the ai_rule_result.html template not properly rendering quality assessments from the assess-rule endpoint. Added logic to handle assessment results with quality score display.

View File

@@ -288,7 +288,7 @@ Return the rules in JSON format:
return " ".join(feedback)
@staticmethod
def generate_cache_key(folder_name: str, folder_type: str, rule_type: str, raw_text: str) -> str:
def generate_cache_key(folder_name: str, folder_type: str, rule_type: str, raw_text: str = '') -> str:
"""Generate a cache key for AI rule requests."""
key_string = f"{folder_name}:{folder_type}:{rule_type}:{raw_text}"
return hashlib.md5(key_string.encode()).hexdigest()

View File

@@ -45,6 +45,20 @@
</div>
{% endfor %}
</div>
{% elif result.assessment %}
<div class="bg-white border rounded-lg p-3 mb-2">
<div class="flex justify-between items-start mb-2">
<h4 class="font-medium text-sm">Rule Quality Assessment</h4>
<span class="badge {% if result.quality_score >= 80 %}badge-success{% elif result.quality_score >= 60 %}badge-warning{% else %}badge-error{% endif %}"
role="status" aria-live="polite">
{{ result.quality_score }}%
</span>
</div>
<p class="text-sm text-gray-700 mb-2">
<strong>Grade:</strong> {{ result.assessment.grade }}<br>
<strong>Feedback:</strong> {{ result.assessment.feedback }}
</p>
</div>
{% endif %}
<script>