Add comprehensive unit tests for BuddAI confidence scoring and fallback mechanisms

- Implemented tests for confidence scoring logic in `test_buddai_confidence.py` and `test_confidence.py`, covering high and low confidence scenarios, escalation thresholds, and validation scoring penalties.
- Created tests for fallback logging functionality in `test_fallback_logging.py`, ensuring fallback prompts are logged correctly and the `/logs` command retrieves log content.
- Developed tests for fallback prompts in `test_fallback_prompts.py`, verifying that specific prompts are used for different models based on confidence levels.
- Generated detailed test reports for multiple test runs, confirming all tests passed successfully.
This commit is contained in:
JamesTheGiblet 2026-01-07 20:27:39 +00:00
parent 27601aa2ba
commit 48716ff271
20 changed files with 2236 additions and 156 deletions

View file

@ -39,6 +39,8 @@ class TestFallbackLogic(unittest.TestCase):
# Setup default mocks
self.ai.validator.validate.return_value = (True, [])
self.ai.hardware_profile.detect_hardware.return_value = "ESP32"
# FIX: Ensure apply_hardware_rules returns a string, not a Mock
self.ai.hardware_profile.apply_hardware_rules.return_value = "mocked_code_response"
self.ai.extract_code = MagicMock(return_value=["void setup() {}"])
def test_fallback_triggered(self):
@ -88,4 +90,4 @@ class TestFallbackLogic(unittest.TestCase):
self.assertNotIn("Fallback Triggered", response)
if __name__ == '__main__':
unittest.main()
unittest.main()