From de7e03f8e7270028999fd5fa462d1d437423b6f8 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 11 Aug 2025 20:07:59 -0700 Subject: [PATCH] cleans up tests --- .serena/memories/integration_test_fixes.md | 1 + app/ai_service.py | 2 +- app/templates/partials/ai_rule_result.html | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .serena/memories/integration_test_fixes.md diff --git a/.serena/memories/integration_test_fixes.md b/.serena/memories/integration_test_fixes.md new file mode 100644 index 0000000..ee47306 --- /dev/null +++ b/.serena/memories/integration_test_fixes.md @@ -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. \ No newline at end of file diff --git a/app/ai_service.py b/app/ai_service.py index d3e8c3b..e7f49df 100644 --- a/app/ai_service.py +++ b/app/ai_service.py @@ -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() diff --git a/app/templates/partials/ai_rule_result.html b/app/templates/partials/ai_rule_result.html index c609770..048f817 100644 --- a/app/templates/partials/ai_rule_result.html +++ b/app/templates/partials/ai_rule_result.html @@ -45,6 +45,20 @@ {% endfor %} + {% elif result.assessment %} +
+
+

Rule Quality Assessment

+ + {{ result.quality_score }}% + +
+

+ Grade: {{ result.assessment.grade }}
+ Feedback: {{ result.assessment.feedback }} +

+
{% endif %}