File size: 1,199 Bytes
131da12
 
d507933
131da12
 
 
 
d507933
131da12
d507933
 
131da12
d507933
 
131da12
d507933
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131da12
 
d507933
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import sys
from unittest.mock import MagicMock, patch

# Add current directory to path for imports
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from main import run_flow_b

def test_run_flow_b_parsing():
    print("Testing run_flow_b parsing and extraction logic...")
    
    mock_response = MagicMock()
    mock_response.content = '{"s": "frustration", "r": "Let\'s simplify this. What do you get when you add the numbers first?"}'
    
    with patch("main.ChatGoogleGenerativeAI") as MockLLM:
        mock_llm_instance = MagicMock()
        mock_llm_instance.invoke.return_value = mock_response
        MockLLM.return_value = mock_llm_instance
        
        state, reply, context, est_in, est_out = run_flow_b(
            message="I am stuck on this step, it is too hard!",
            api_key="fake-api-key"
        )
        
        assert state == "frustration", f"Expected frustration, got {state}"
        assert "simplify" in reply, f"Expected reply to contain simplification, got {reply}"
        assert est_in > 0
        assert est_out > 0
        
        print("Mocked run_flow_b test passed!")

if __name__ == "__main__":
    test_run_flow_b_parsing()