
    {ki                         d dl Zd dlmc mZ d dlZd dlmZ d dl	m
Z
 d dlmZmZmZmZ deddfdZdeddfdZdeddfd	Zdeddfd
ZdeddfdZdeddfdZdeddfdZdS )    N)Path)build_context_bundle)ContextSourceDecisionPacketMeetingBriefMeetingInputtmp_pathreturnc                    | dz  }|                                  |dz                      dd           |dz                      dd           t          dt                      t	          d	          t          d
dddgd          g          }t          || dz            }|j        d         }|j        }|j	        }d} ||          }|sdt          j        |          t          j        |          t          j        |          t          j        |          t          j        |          dz  }	t          t          j        |	                    d x}x}x}x}}d S )Ndocsb.mdButf-8encodingza.mdAtopicdecision_to_make	directoryz./docs**/*.md   )typepathpurposeinclude	max_filesr   briefdecision_packetcontext_sourcesmeeting.yamlr   zkassert %(py9)s
{%(py9)s = %(py5)s
{%(py5)s = %(py3)s
{%(py3)s = %(py1)s.source_path
}.endswith
}(%(py7)s)
})py1py3py5py7py9)mkdir
write_textr   r   r   r   r   	documentssource_pathendswith
@pytest_ar	_safereprAssertionError_format_explanation)
r	   docs_dirmeeting_inputbundle@py_assert0@py_assert2@py_assert4@py_assert6@py_assert8@py_format10s
             @/root/projects/multi-agents-meeting/tests/test_context_loader.py3test_directory_sources_are_sorted_before_truncationr;      s   & HNN""3"999""3"999 nn&@@@ "  
	  M "-N1JKKFA;*;*3;F;33F;;;;;;;;;;;;*;;;;3;;;;F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    c           
      |   | dz  }|                     d           t          dt                      t          d          t	          ddd          g	          }t          || d
z            }|j        }g }||k    }|st          j        d|fd||f          dt          j
                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|j        d         d         }	d}|	|k    }
|
slt          j        d|
fd|	|f          t          j        |	          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}	x}
}d S )Nblob.bins    r   r   file
./blob.binbinaryr   r   r   r   r"   ==z1%(py2)s
{%(py2)s = %(py0)s.documents
} == %(py5)sr3   py0py2r%   assert %(py7)sr&   r   reasonz%(py1)s == %(py4)sr#   py4assert %(py6)spy6)write_bytesr   r   r   r   r   r*   r-   _call_reprcompare@py_builtinslocals_should_repr_global_namer.   r/   r0   skipped_paths)r	   binary_pathr2   r3   @py_assert1r6   @py_assert3@py_format6@py_format8r4   r5   @py_format5@py_format7s                r:   'test_binary_file_is_skipped_with_reasonr]   "   s   Z'KO,,, nn&@@@vL(KKK
	  M "-N1JKKF!r!r!!!!!!!!!!r!!!!!!!!!!!!6!!!!!6!!!!!!!!!!r!!!!!!!!!!!!!!!!!!!!!!!!!!!"8,88,8888888888,88888,888888888888888888888888888888888r<   c           
         | dz  }|                     dd           | dz  }|                    |           t          dt                      t	          d          t          dd	d
          g          }t          || dz            }|j        }g }||k    }|st          j	        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }	t          t          j        |	                    d x}x}}|j        d         d         }
d}|
|k    }|slt          j	        d|fd|
|f          t          j        |
          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}
x}}d S )Nz	target.mdhellor   r   zlink.mdr   r   r?   z	./link.mdlinkrB   r   r"   rC   rE   r3   rF   rI   r&   r   rJ   symlinkrK   rL   rN   rO   )r)   
symlink_tor   r   r   r   r   r*   r-   rQ   rR   rS   rT   r.   r/   r0   rU   )r	   targetr`   r2   r3   rW   r6   rX   rY   rZ   r4   r5   r[   r\   s                 r:   #test_symlink_is_skipped_with_reasonrd   5   s2   #F
g000iDOOF nn&@@@vKHHH
	  M "-N1JKKF!r!r!!!!!!!!!!r!!!!!!!!!!!!6!!!!!6!!!!!!!!!!r!!!!!!!!!!!!!!!!!!!!!!!!!!!"8,9	9,	9999999999,	99999,9999	99999999999999999999999999999r<   c           
         | dz  }|                     dd           |                    d           	 t          dt                      t	          d          t          dd	d
          g          }t          || dz            }|                    d           n# |                    d           w xY w|j        }g }||k    }|st          j	        d|fd||f          dt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}x}}|j        d         d         }	d}|	|k    }
|
slt          j	        d|
fd|	|f          t          j        |	          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}	x}
}d S )Nz	secret.mdhiddenr   r   r   r   r   r?   z./secret.mdsecretrB   r   r"   i  rC   rE   r3   rF   rI   r&   rJ   
unreadablerK   rL   rN   rO   )r)   chmodr   r   r   r   r   r*   r-   rQ   rR   rS   rT   r.   r/   r0   rU   )r	   r   r2   r3   rW   r6   rX   rY   rZ   r4   r5   r[   r\   s                r:   +test_unreadable_file_is_skipped_with_reasonrj   J   sT   k!DOOHwO///JJqMMM$..*GDDD6xPPP	
 
 
 &mX5NOO

5

5!r!r!!!!!!!!!!r!!!!!!!!!!!!6!!!!!6!!!!!!!!!!r!!!!!!!!!!!!!!!!!!!!!!!!!!!"8,<<,<<<<<<<<<<,<<<<<,<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<s   AB B1c           
      ~   | dz  }|                     d           t          dt                      t          d          t	          ddd          g	          }t          || d
z            }|j        }t          |          }d}||k    }|st          j	        d|fd||f          dt          j                    v st          j        t                    rt          j        t                    nddt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }	t          t          j        |	                    d x}x}x}}d}
|j        d         }|j        }|
|v }|st          j	        d|fd|
|f          t          j        |
          t          j        |          t          j        |          dz  }dd|iz  }t          t          j        |                    d x}
x}x}}d S )Nzbad.txts
   validtextr   r   r?   z	./bad.txttextrB   r   r"   r   rC   )zO%(py5)s
{%(py5)s = %(py0)s(%(py3)s
{%(py3)s = %(py1)s.documents
})
} == %(py8)slenr3   )rG   r#   r$   r%   py8zassert %(py10)spy10validr   )in)z/%(py1)s in %(py6)s
{%(py6)s = %(py4)s.excerpt
})r#   rM   rO   zassert %(py8)srn   )rP   r   r   r   r   r   r*   rm   r-   rQ   rR   rS   rT   r.   r/   r0   excerpt)r	   r   r2   r3   r5   r6   @py_assert7r7   @py_format9@py_format11r4   rX   @py_assert5r\   s                 r:   1test_utf8_replacement_behavior_preserves_documentrw   a   s   iD%&&& nn&@@@vKHHH
	  M "-N1JKKF%3  %A% A%%%%%%%%%% A%%%%%%%%%%%%3%%%%%3%%%%%%%%%%%%%v%%%%%v%%%%%%%%%% %%%%A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1f&q)1)11711111111111711111171111)111111111111111111111111111111111111r<   c           
         | dz  }|                     d           t          dt                      t          d          t	          ddd          g	          }t          || d
z            }|j        d         }t          |          }ddh}||k    }|st          j	        d|fd||f          dt          j                    v st          j        t                    rt          j        t                    ndt          j        |          t          j        |          t          j        |          dz  }dd|iz  }	t          t          j        |	                    d x}x}x}}d S )Nr>   s    r   r   r?   r@   rA   rB   r   r"   r   r   rJ   rC   )z0%(py4)s
{%(py4)s = %(py0)s(%(py2)s)
} == %(py7)sset)rG   rH   rM   r&   zassert %(py9)sr'   )rP   r   r   r   r   r   rU   ry   r-   rQ   rR   rS   rT   r.   r/   r0   )
r	   r   r2   r3   rW   rX   r7   rv   rZ   r9   s
             r:   *test_skipped_paths_include_path_and_reasonrz   t   s   j D[!!! nn&@@@&FxXXXY	  M "-N1JKKF#A&=3&''=FH+=='+==========='+=============3=====3======&===='====+================================r<   c                    | dz                       dd           | dz  }|                                 |dz                       dd           t          dt                      t	          d	          t          d
dddg          g          }t          || dz            }d |j        D             }t          |          }t          |          }t          |          }||k    }|st          j        d|fd||f          dt          j                    v st          j        t                    rt          j        t                    nddt          j                    v st          j        |          rt          j        |          ndt          j        |          dt          j                    v st          j        t                    rt          j        t                    nddt          j                    v st          j        t                    rt          j        t                    nddt          j                    v st          j        |          rt          j        |          ndt          j        |          t          j        |          dz  }	dd|	iz  }
t!          t          j        |
                    d x}x}x}}d S )Nza__b.mdflatr   r   ar   nestedr   r   r   .r   r   )r   r   r   r   r   r"   c                     g | ]	}|j         
S  )document_id).0documents     r:   
<listcomp>zNtest_document_ids_do_not_collide_for_flat_and_nested_paths.<locals>.<listcomp>   s    JJJXH(JJJr<   rC   )zn%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py11)s
{%(py11)s = %(py5)s(%(py9)s
{%(py9)s = %(py6)s(%(py7)s)
})
}rm   document_idsry   )rG   r#   r$   r%   rO   r&   r'   py11zassert %(py13)spy13)r)   r(   r   r   r   r   r   r*   rm   ry   r-   rQ   rR   rS   rT   r.   r/   r0   )r	   
nested_dirr2   r3   r   r5   r8   @py_assert10r6   @py_format12@py_format14s              r:   :test_document_ids_do_not_collide_for_flat_and_nested_pathsr      s   	%%fw%???CJ&$$X$@@@ nn&@@@{fykZZZ
	  M "-N1JKKFJJ9IJJJL|6C$5$56$5 6 66 66666666666 666666666666636666636666666666666|66666|66666666666666666666666666666666666C66666C666666666666666666666666$56666 66666666666666666666666666666666r<   )builtinsrR   _pytest.assertion.rewrite	assertionrewriter-   ospathlibr   core.context_loaderr   core.modelsr   r   r   r   r;   r]   rd   rj   rw   rz   r   r   r<   r:   <module>r      si                				       4 4 4 4 4 4 Q Q Q Q Q Q Q Q Q Q Q Q<$ <4 < < < <49d 9t 9 9 9 9&:$ :4 : : : :*=$ =4 = = = =.2 2 2 2 2 2&> >$ > > > > 7 7RV 7 7 7 7 7 7r<   