You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
import sys
|
|
import os
|
|
import json
|
|
from unittest.mock import MagicMock
|
|
|
|
# Mock qwen_agent before importing the tool
|
|
sys.modules['qwen_agent'] = MagicMock()
|
|
sys.modules['qwen_agent.tools'] = MagicMock()
|
|
|
|
# Add project root to sys.path
|
|
project_root = "/home/aimo/dev/be-ircfa"
|
|
if project_root not in sys.path:
|
|
sys.path.append(project_root)
|
|
|
|
# Now import the tool
|
|
from src.ircfa_interaction.tools.root_cause_spln_tool import RootCauseSPLNTool
|
|
|
|
def test_bfp_override():
|
|
# We need to mock the BaseTool initialization if it calls super().__init__
|
|
# and expects certain things. But since we mocked the module, it should be fine.
|
|
|
|
tool = RootCauseSPLNTool()
|
|
|
|
print("\n[TEST] Calling tool for BFP with a DIFFERENT problem name...")
|
|
params = {
|
|
"equipment_type": "BOILER FEEDWATER PUMP TURBINE",
|
|
"problem": "high_vibration" # This should be overridden
|
|
}
|
|
|
|
# We call 'call' method. We might need to mock load_tool_guide since it's imported inside call.
|
|
# But let's see if it works as is.
|
|
try:
|
|
result = tool.call(params)
|
|
print("\n[TEST] Success! Check the DEBUG prints above.")
|
|
# We can also check if the result contains insufficient_discharge_pressure
|
|
if "insufficient_discharge_pressure" in result.lower():
|
|
print("[TEST] VERIFIED: Result contains forced problem 'insufficient_discharge_pressure'")
|
|
else:
|
|
print("[TEST] FAILED: Result does NOT contain forced problem.")
|
|
|
|
except Exception as e:
|
|
print(f"[TEST] Error during execution: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
test_bfp_override()
|