
    ~[i*                         d Z ddlZej                  j                  dd       ddlZddlmZ ddlmZm	Z	  ee	      Z
 G d d      Z G d d	      Z G d
 d      Zedk(  r ej                  edg       yy)u  
Task 115-1 테스트: 팀장 가이드 분리 및 프롬프트 크기 게이트

대상:
  1. team_prompts.py의 build_prompt() 변경:
     - 가이드 텍스트(작업 철학, 실패 시나리오, 셀프QC)를 파일 참조로 분리
     - teamlead-guide.md 경로 반환 확인
     - 기존 가이드 텍스트가 직접 포함되지 않는지 확인
     - level별 분기 동작 확인 (normal은 셀프QC만, critical은 마아트 추가, security는 로키 추가)

  2. dispatch.py의 dispatch() 함수 변경:
     - 프롬프트 크기 검증 게이트 추가
     - 직접 호출은 하지 않고, 소스 코드와 build_prompt 길이로 간접 검증

실행:
    pytest /home/jay/workspace/teams/dev1/test_task_115_1.py -v
    Nz/home/jay/workspace)Pathbuild_promptTEAMLEAD_GUIDE_PATHc                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)TestTeamleadGuideSeparationu3   팀장 가이드 분리 및 파일 참조 테스트c                 H    t         j                         sJ dt                 y)u2   teamlead-guide.md 파일이 존재하는지 확인u#   팀장 가이드 파일이 없음: N)
GUIDE_PATHexists)selfs    1/home/jay/workspace/teams/dev1/test_task_115_1.pytest_guide_file_existsz2TestTeamleadGuideSeparation.test_guide_file_exists"   s!      "V&I*$VV"    c                 n    t         j                  d      }g d}|D ]  }||v rJ d| d|dd          y)uF   teamlead-guide.md에 핵심 텍스트가 포함되어 있는지 확인utf-8encoding)u   계획 우선 원칙u   비정상 입력u   스스로 점검	   마아트   로키u   가이드에 'u'   ' 포함 필수, 실제 내용 일부: N   )r
   	read_text)r   
guide_text
core_textstexts       r   +test_guide_file_content_includes_core_textszGTestTeamleadGuideSeparation.test_guide_file_content_includes_core_texts&   s[    ))7);


  	xD:%wv=deoptqteudv'ww%	xr   c                 P    t        dddd      }t        |v sJ dt         d       y)	uR   build_prompt() 반환값에 teamlead-guide.md 경로 참조가 포함되어야 함	dev1-teamtask-test-1   테스트 작업normallevelu!   프롬프트에 가이드 경로(u   )가 포함되어야 함Nr   r   prompts     r   %test_build_prompt_includes_guide_pathzATestTeamleadGuideSeparation.test_build_prompt_includes_guide_path6   s<    k=:LT\] #f, 	^/0C/DD\]	^,r   c                 Z    t        dddd      }ddg}|D ]  }||vrJ d|d	d
          y	)uQ   normal 레벨: 기존 가이드 텍스트가 직접 포함되지 않는지 확인r   r   r   r    r!   u2   계획 우선 원칙
- 코딩 전 작업을 분석u1   비정상 입력/상태
- 이 기능의 입력이uD   프롬프트에 직접 가이드 텍스트가 포함되면 안 됨: N2   r   )r   r$   unwanted_patternspatterns       r   <test_build_prompt_does_not_include_direct_guide_texts_normalzXTestTeamleadGuideSeparation.test_build_prompt_does_not_include_direct_guide_texts_normal>   sd    k=:LT\] B@
 ) 	fG&( fVW^_b`bWcVdef(	fr   c                 V    t        dddd      }d|v sJ d       t        |v sJ d       y	)
u/   normal 레벨: 셀프QC 파일 참조만 포함r   r   r   r    r!   	   셀프 QCu4   normal 레벨에 '셀프 QC' 문구가 있어야 함u-   셀프QC 섹션에서 가이드 파일 참조Nr   r#   s     r   2test_build_prompt_normal_includes_selfqc_referencezNTestTeamleadGuideSeparation.test_build_prompt_normal_includes_selfqc_referenceM   s>    k=:LT\] f$\&\\$"f,].]],r   c                 l    t        dddd      }d|v sJ d       d|v sJ d	       t        |v sJ d
       y)u3   critical 레벨: 셀프QC + 마아트 참조 포함r   r   r   criticalr!   r-   u6   critical 레벨에 '셀프 QC' 문구가 있어야 함r   u6   critical 레벨에 '마아트' 문구가 있어야 함u-   critical 레벨에서 가이드 파일 참조Nr   r#   s     r   2test_build_prompt_critical_includes_maat_referencezNTestTeamleadGuideSeparation.test_build_prompt_critical_includes_maat_referenceU   sR    k=:LT^_ f$^&^^$f$^&^^$"f,].]],r   c                     t        dddd      }d|v sJ d       d|v sJ d	       d
|v sJ d       t        |v sJ d       y)u<   security 레벨: 셀프QC + 마아트 + 로키 참조 포함r   r   r   securityr!   r-   u6   security 레벨에 '셀프 QC' 문구가 있어야 함r   u6   security 레벨에 '마아트' 문구가 있어야 함r   u3   security 레벨에 '로키' 문구가 있어야 함u-   security 레벨에서 가이드 파일 참조Nr   r#   s     r   2test_build_prompt_security_includes_loki_referencezNTestTeamleadGuideSeparation.test_build_prompt_security_includes_loki_reference^   sf    k=:LT^_ f$^&^^$f$^&^^$6!X#XX!"f,].]],r   c                     t        dddd      }t        dddd      }t        dddd      }d|vsJ d	       d
|vsJ d       d|v sJ d       d
|vsJ d       d|v sJ d       d
|v sJ d       y)u:   level별 분기 동작이 명확히 구분되는지 확인r   r   r   r    r!   r0   r3   r   u5   normal 레벨에는 마아트 참조가 없어야 함r   u2   normal 레벨에는 로키 참조가 없어야 함u7   critical 레벨에는 마아트 참조가 있어야 함u4   critical 레벨에는 로키 참조가 없어야 함u7   security 레벨에는 마아트 참조가 있어야 함u4   security 레벨에는 로키 참조가 있어야 함Nr(   )r   normal_promptcritical_promptsecurity_prompts       r   -test_build_prompt_level_branching_consistencyzITestTeamleadGuideSeparation.test_build_prompt_level_branching_consistencyh   s    $[-AS[cd&{MCU]gh&{MCU]gh -/h1hh/},b.bb, o-h/hh-.f0ff. o-h/hh-?*b,bb*r   N)__name__
__module____qualname____doc__r   r   r%   r+   r.   r1   r4   r9    r   r   r   r      s5    =Wx ^f^^^cr   r   c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)TestPromptSizeGateu'   프롬프트 크기 게이트 테스트c                     t        d      }|j                         sJ d       |j                  d      }g d}|D ]  }||v rJ d| d        y)	uN   dispatch.py에 프롬프트 크기 검증 게이트 코드가 있는지 확인z/home/jay/workspace/dispatch.pyu   dispatch.py 파일이 없음r   r   )u   프롬프트가u   자입니다3000u   dispatch.py에 'u6   ' 문자열이 있어야 함 (크기 게이트 코드)N)r   r   r   )r   dispatch_filedispatch_textgate_patternsr*   s        r   (test_dispatch_py_contains_size_gate_codez;TestPromptSizeGate.test_dispatch_py_contains_size_gate_code~   sv    >?##%E'EE%%///A
 % 	cGm+ c"7)+abc+	cr   c                 x    t        dddd      }t        |      }|dkD  sJ d| d       |d	k  sJ d
| d       y)uB   normal 레벨 프롬프트 길이가 합리적 범위인지 확인r   r   r   r    r!        프롬프트가 너무 짧음:    자      프롬프트가 3000자 초과: Nr   lenr   r$   
prompt_lens      r   2test_build_prompt_returns_reasonable_length_normalzETestPromptSizeGate.test_build_prompt_returns_reasonable_length_normal   sX    k=:LT\][
CR#B:,c!RRD T$DZLPS"TT r   c                 x    t        dddd      }t        |      }|dkD  sJ d| d       |d	k  sJ d
| d       y)uD   critical 레벨 프롬프트 길이가 합리적 범위인지 확인r   r   r   r0   r!   rH   rI   rJ   rK   rL   NrM   rO   s      r   4test_build_prompt_returns_reasonable_length_criticalzGTestPromptSizeGate.test_build_prompt_returns_reasonable_length_critical   sX    k=:LT^_[
CR#B:,c!RRD T$DZLPS"TT r   c                 x    t        dddd      }t        |      }|dkD  sJ d| d       |d	k  sJ d
| d       y)uD   security 레벨 프롬프트 길이가 합리적 범위인지 확인r   r   r   r3   r!   rH   rI   rJ   i  u    프롬프트가 3100자 초과: NrM   rO   s      r   4test_build_prompt_returns_reasonable_length_securityzGTestPromptSizeGate.test_build_prompt_returns_reasonable_length_security   sZ    k=:LT^_[
 CR#B:,c!RRD T$DZLPS"TT r   c                 j    t        dddd      }t        |      dk  sJ d       t        |v sJ d       y	)
uL   가이드 분리로 인해 프롬프트 길이가 줄었는지 간접 검증r   r   r   r    r!   rK   u@   가이드 분리 후 프롬프트는 3000자 미만이어야 함u.   가이드 파일 참조가 포함되어야 함N)r   rN   r   r#   s     r   1test_prompt_length_reduced_after_guide_separationzDTestPromptSizeGate.test_prompt_length_reduced_after_guide_separation   sF    
 k=:LT\] 6{T!e#ee! #f,^.^^,r   N)	r:   r;   r<   r=   rF   rQ   rS   rU   rW   r>   r   r   r@   r@   {   s#    1c$UUU_r   r@   c                       e Zd ZdZd Zy)TestIntegrationu   통합 테스트c           
      2   g d}g d}|D ]  }|D ]  }t        |dd|      }|sJ | d| d       t        |v sJ | d| d       t        |      d	kD  sJ | d| d
t        |       d       t        |      dk  rlJ | d| dt        |       d         y)uR   모든 팀과 레벨 조합에서 유효한 프롬프트를 생성하는지 확인)r   z	dev2-teamz	dev3-team)r    r0   r3   ztask-integration-1u   통합 테스트 작업r!   /u   : 프롬프트가 비어있음u#   : 가이드 파일 참조가 없음rH   u!   : 프롬프트가 너무 짧음 (u   자)i  u"   : 프롬프트가 3200자 초과 (N)r   r   rN   )r   teamslevelsteam_idr"   r$   s         r   *test_all_team_levels_produce_valid_promptsz:TestIntegration.test_all_team_levels_produce_valid_prompts   s    73 	\G \%g/CE^fkl Q'!E72PQQv*f4 Liq'JKL46{S( [iq'HVUYZ[( 6{T) \iq'I#f+VZ[\)\	\r   N)r:   r;   r<   r=   r_   r>   r   r   rY   rY      s    \r   rY   __main__z-v)r=   syspathinsertpytestpathlibr   prompts.team_promptsr   r   r
   r   r@   rY   r:   main__file__r>   r   r   <module>ri      s   $  ( )   B %&
Yc Ycx=_ =_@\ \0 zFKK4 ! r   