
    <Fj              
       f   d Z ddlZddlZddlZej                  j                  dej                  j                  ej                  j                  ej                  j                  e                         ddl	m
Z
  G d d      Z G d dej                        Zedk(  r ej                          yy)	zUnit tests for frustration detection state machine.

This test does not call the real side model; it only verifies that the
frustration score, pending flag, and notifications behave as expected.
    N)Brainc                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)

_FakePanelc                      g | _         g | _        y N)issuesragsselfs    K/Users/admin/workspace/jyq/kimi-copilot/tests/test_frustration_detection.py__init__z_FakePanel.__init__   s    	    c                 >    | j                   j                  ||f       y r   )r   appendr   argskwargss      r   	add_issuez_FakePanel.add_issue   s    D&>*r   c                 >    | j                   j                  ||f       y r   )r	   r   r   s      r   add_ragz_FakePanel.add_rag   s    		$(r   c                      y r    r   s      r   add_interventionz_FakePanel.add_intervention       r   c                 
    dg fS )NFr   r   s      r   is_repeatedz_FakePanel.is_repeated   s    byr   c                     g S r   r   r   s      r   find_relatedz_FakePanel.find_related"   s    	r   c                      y r   r   r
   s    r   savez_FakePanel.save%   r   r   c                      y r   r   r
   s    r   render_htmlz_FakePanel.render_html(   r   r   N)__name__
__module____qualname__r   r   r   r   r   r   r    r"   r   r   r   r   r      s*    +)r   r   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)TestFrustrationDetectionc                      g  _         t        dt                fd       _        d j                  j                  j                  di       j                  di       d<    j                  j                          y )Nzconfig.yamlc                 :    j                   j                  |       S r   )notificationsr   )msgr   s    r   <lambda>z0TestFrustrationDetection.setUp.<locals>.<lambda>2   s    (:(:(A(A#(F r   )config_pathpanelnotify_callbackFcopilotreal_time_scanenabled)r*   r   r   brainconfig
setdefault_reset_frustration_stater
   s   `r   setUpzTestFrustrationDetection.setUp-   sg    %,F

 ch

$$Y3>>?OQSTU^_

++-r   c                    | j                   j                  d       | j                  | j                   j                  d       | j	                  | j                   j
                         | j                  t        | j                        d       y )Nu,   帮我写一个读取 config.yaml 的函数
r   )r3   feed_user_inputassertEqualfrustration_scoreassertFalsepending_frustration_summarylenr*   r
   s    r   test_no_frustration_by_defaultz7TestFrustrationDetection.test_no_frustration_by_default9   sb    

""#RS55q9??@T//0!4r   c                     | j                   j                  d       | j                  | j                   j                  d       y )N   怎么还不行
r   )r3   r9   assertGreaterr;   r
   s    r   !test_frustration_score_incrementsz:TestFrustrationDetection.test_frustration_score_increments?   s/    

""#674::77;r   c                    | j                   j                  d       | j                   j                  d       | j                  | j                   j                         | j                  t	        d | j
                  D                     y )NrA      搞了这么久
c              3   $   K   | ]  }d |v  
 yw)u   不太满意Nr   ).0ns     r   	<genexpr>zNTestFrustrationDetection.test_pending_flag_and_notification.<locals>.<genexpr>H   s     LANa/Ls   )r3   r9   
assertTruer=   anyr*   r
   s    r   "test_pending_flag_and_notificationz;TestFrustrationDetection.test_pending_flag_and_notificationC   s[    

""#67

""#67

>>?L9K9KLLMr   c                      j                   j                  d        j                   j                  d       g  j                   j                  } fd}| j                   _        	  j                   j                  d        j	                  t              d       | j                   _        y # | j                   _        w xY w)NrA   rE   c                  \     j                  d       j                  j                          y N   )r   r3   r6   )calledr   s   r   _mockzMTestFrustrationDetection.test_resolution_triggers_summary_call.<locals>._mockQ   s    MM!JJ//1r   "   搞定了，现在应该可以了
rP   )r3   r9   _invoke_frustration_rag_summaryfeed_kimi_outputr:   r>   )r   originalrR   rQ   s   `  @r   %test_resolution_triggers_summary_callz>TestFrustrationDetection.test_resolution_triggers_summary_callJ   s    

""#67

""#67::==	2
 6;

2	BJJ''(MNS[!,9ADJJ6DJJ6s   )6B1 1Cc                     g fd| j                   _        | j                   j                  d       | j                  t	              d       y )Nc                  &     j                  d      S rO   )r   )rQ   s   r   r,   zNTestFrustrationDetection.test_no_summary_without_frustration.<locals>.<lambda>_   s    V]]1=M r   rS   r   )r3   rT   rU   r:   r>   )r   rQ   s    @r   #test_no_summary_without_frustrationz<TestFrustrationDetection.test_no_summary_without_frustration]   s;    5M

2

##$IJVa(r   N)	r#   r$   r%   r7   r?   rC   rL   rW   rZ   r   r   r   r'   r'   ,   s"    
.5<NB&)r   r'   __main__)__doc__ossysunittestpathinsertdirnameabspath__file__r3   r   r   TestCaser'   r#   mainr   r   r   <module>rg      s    
 
  277??277??277??83L#MN O  65)x00 5)p zHMMO r   