
    h
                     P   S r SSKrSSKJs  Jr  SSKrSSKrSSK	r	SSK
Jr  SSKJr  SSKrSSKJr  \R"                  R%                  \" \" \5      R+                  5       R,                  S   5      5        SSKJr   " S S	\	R2                  5      r\S
:X  a  \	R8                  " 5         gg)z8
Tests for the corrected build_project_registry script.
    N)Path)TemporaryDirectory)patch   )build_project_registryc                   0    \ rS rSrSrS rS rS rS rSr	g)	!TestCorrectedBuildProjectRegistry   zaTests for the corrected build_project_registry script that uses TRACE_INDEX.yml for descriptions.c                 6   [        5       U l        [        U R                  R                  5      R	                  5       U l        U R
                  S-  U l        U R                  R                  SSS9  U R
                  S-  U l        U R                  S-  U l	        U R                  R                  SSS9  U R                  S-  [        l        U R                  S-  [        l        U R                  S-  [        l        U R                  S	-  R                  SSS9  U R                  S	-  S
-  R                  5         U R                  S	-  S-  R                  5         U R
                  S-  S-  R                  SSS9  U R
                  S-  S-  S-  R                  5         g )NscriptsT)parentsexist_okprojectreportszTRACE_INDEX.ymlzproject_registry.jsonPROJECT_REGISTRY.md	proposalszNEW_PROPOSAL.mdzQA_GATE_IMPLEMENTATION_PLAN.mdapidocszsome_api_doc.md)r   tmpdirr   nameresolve	repo_rootscripts_dirmkdirproject_dirreports_dirr   TRACE_INDEX_PATHOUTPUT_JSON	OUTPUT_MDtouchselfs    =/root/zotify-API/tests/scripts/test_build_project_registry.pysetUp'TestCorrectedBuildProjectRegistry.setUp   sp   (*dkk../779  >>I5td;>>I5++i7td; 372B2BEV2V/-1-=-=@W-W*+/+;+;>S+S( 
		K	'..td.K			K	'*;	;BBD			K	'*J	JQQS	%	&	(//t/L	%	&	(+<	<CCE    c                 8    U R                   R                  5         g )N)r   cleanupr!   s    r#   tearDown*TestCorrectedBuildProjectRegistry.tearDown/   s    r&   c           	      N   Sn[         R                  R                  U5        [         R                  " [         R                  U R                  S-  U R
                  S-  [         R                  U R                  U R                  S9n[         R                  " U[         R                  5        U R                  [         R                  R                  5       5        [        [         R                  S5       n[        R                  " U5      nSSS5        U R                  [!        U5      S5        U Vs0 s H  oDS   US	   _M     nnU Vs0 s H  oDS   US
   _M     nnU R#                  SU5        U R%                  SU5        U R                  US   S5        U R                  US   S5        U R                  US   S5        U R                  US   S5        U R                  [         R                  R                  5       5        [         R                  R'                  5       nU R#                  SU5        U R#                  SU5        U R#                  SU5        U R#                  SU5        U R#                  SU5        U R%                  SU5        g! , (       d  f       GN= fs  snf s  snf )zz
Test that the registry generation logic correctly pulls descriptions
from the mock TRACE_INDEX.yml, not a hardcoded map.
a  
artifacts:
  - path: project/proposals/NEW_PROPOSAL.md
    description: "This is the correct description from TRACE_INDEX."
  - path: project/proposals/QA_GATE_IMPLEMENTATION_PLAN.md
    description: "This is also the correct description."
  - path: api/docs/some_api_doc.md
    description: "This description for a non-project file should be ignored."
  - path: project/proposals/MISSING_FILE.md
    description: "A file that does not exist on disk"
r   project_registry_extras.ymltrace_index_pathproject_registry_md_pathextras_file_pathoutput_json_pathr   r   rN   pathstatusnotes!project/proposals/NEW_PROPOSAL.mdzapi/docs/some_api_doc.md
registeredz!project/proposals/MISSING_FILE.mdmissingz1This is the correct description from TRACE_INDEX.z0project/proposals/QA_GATE_IMPLEMENTATION_PLAN.mdz%This is also the correct description.z#`project/proposals/NEW_PROPOSAL.md`z#`project/proposals/MISSING_FILE.md`z| N/A |z| missing |)r   r   
write_textbuild_registryr   r   r   r   generate_markdownr   
assertTrueexistsopenjsonloadassertEquallenassertInassertNotIn	read_text)r"   trace_contentregistry_datafitem
status_mapdesc_map
md_contents           r#   6test_registry_generation_uses_trace_index_descriptionsXTestCorrectedBuildProjectRegistry.test_registry_generation_uses_trace_index_descriptions2   s?   

 	//::=I /==3DD%)%5%58M%M!--0MM3??((nn
 	00@V@`@`a 	.::AACD(44c:a IIaLM ; 	]+Q/?LM}t6lDN2}
M<IJMDL$w-/MJ 	9:F3Z@ 	$GH,W$GH)T 	"EFH{|"TUW~ 	.88??AB+55??A
;ZHI:V;ZHi,mZ03Z@; ;:
 NJs   1J/JJ"
Jc           	      f   U R                   S-  S-  R                  5         Sn[        R                  R	                  U5        [        R
                  " [        R                  U R                   S-  U R                  S-  [        R                  U R                   U R                  S9n[        R                  " U[        R                  5        [        [        R                  S5       n[        R                  " U5      nSSS5        U Vs0 s H  oDS	   US
   _M     nnU R                  US   S/5        U R                  US   SS/5        [        R                  R                  5       nU R!                  SU5        U R!                  SU5        U R!                  SU5        g! , (       d  f       N= fs  snf )zBTests that Task IDs are correctly propagated to JSON and Markdown.r   zANOTHER_PROPOSAL.mda  
artifacts:
  - path: project/proposals/NEW_PROPOSAL.md
    description: "A proposal with a task ID."
    task_ids: ["FEAT-123"]
  - path: project/proposals/ANOTHER_PROPOSAL.md
    description: "A proposal with multiple task IDs."
    task_ids: ["FEAT-456", "BUG-789"]
r   r,   r-   r2   Nr4   task_idsr7   zFEAT-123z%project/proposals/ANOTHER_PROPOSAL.mdzFEAT-456zBUG-789z| Task ID(s) |z
`FEAT-123`z`FEAT-456`, `BUG-789`)r   r    r   r   r:   r;   r   r   r   r<   r   r?   r@   rA   rB   rF   rD   )r"   rG   rH   rI   rJ   task_id_maprM   s          r#   test_task_id_propagation:TestCorrectedBuildProjectRegistry.test_task_id_propagationp   sw   			K	'*?	?FFH 	//::=I /==3DD%)%5%58M%M!--0MM3??((nn
 	00@V@`@`a (44c:a IIaLM ; CPP-$F|T*%55-P%HIJ<X%LMPZ\eOfg ,55??A
&
3lJ/-z: ;: Qs   $FF.
F+)r   r   r   r   r   N)
__name__
__module____qualname____firstlineno____doc__r$   r)   rN   rS   __static_attributes__ r&   r#   r	   r	      s    kF0<A|%;r&   r	   __main__)rY   builtins@py_builtins_pytest.assertion.rewrite	assertionrewrite
@pytest_arr@   sysunittestpathlibr   tempfiler   osunittest.mockr   r4   appendstr__file__r   r   r   r   TestCaser	   rU   mainr[   r&   r#   <module>rn      s      
   ' 	  DN**,44Q78 9 *A;(9(9 A;H zMMO r&   