
    ^h                         S r SSKrSSKrSSKrSSKrSSKJs  Jr  \R                  R                  \R                  R                  \5      5      r " S S\R                  5      rg)zTest the bundler tools.    Nc                   n    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rSrg)TestBundlerTools   c                 8    [         R                  " 5       U l        g )N)tempfilemkdtemptmpselfs    d/home/james-whalen/.local/lib/python3.13/site-packages/nbclassic/bundler/tests/test_bundler_tools.pysetUpTestBundlerTools.setUp   s    ##%    c                 B    [         R                  " U R                  SS9  g )NT)ignore_errors)shutilrmtreer	   r
   s    r   tearDownTestBundlerTools.tearDown   s    dhhd3r   c                 l    [         R                  " SSS.5      nU R                  [        U5      S5        g)z4Should find no references in a regular HTML comment.z!<--
a
b
c
-->markdownsource	cell_typer   N)toolsget_cell_reference_patternsassertEquallenr   no_referencess     r   test_get_no_cell_references,TestBundlerTools.test_get_no_cell_references   s9    99 E 	;  !
 	]+Q/r   c                     SSS.n[         R                  " U5      nU R                  SU;   =(       a    SU;   [        U5      5        U R	                  [        U5      S[        U5      5        g)zGShould find two references and ignore a comment within an HTML comment.r   z <!--associate:
a
b/
#comment
-->r   r   ab/   Nr   r   
assertTruestrr   r   r   cell
referencess      r   2test_get_cell_reference_patterns_comment_multilineCTestBundlerTools.test_get_cell_reference_patterns_comment_multiline   ^    & 2 
 66t<
z)@dj.@#j/RZ!S_=r   c                     SSS.n[         R                  " U5      nU R                  SU;   =(       a    SU;   =(       a    SU;   [        U5      5        U R	                  [        U5      S[        U5      5        g)	z4Should find three references within an HTML comment.r   z!<!--associate:c
a
b/
#comment
-->r$   r%   r&   c   Nr(   r+   s      r   :test_get_cell_reference_patterns_comment_trailing_filenameKTestBundlerTools.test_get_cell_reference_patterns_comment_trailing_filename)   k    & 2 
 66t<
z)Vdj.@VSJEVX[\fXghZ!S_=r   c                     U R                  [        R                  5        [        R                  " SSS.5      nU R                  [	        U5      S5        g)zBShould find no references in a fenced code block in a *code* cell.z```
foo
bar
baz
```
coder   r   N)r)   r   r   r   r   r   s     r   (test_get_cell_reference_patterns_precode9TestBundlerTools.test_get_cell_reference_patterns_precode4   sK    99:99 E
 ;  	]+Q/r   c                     SSS.n[         R                  " U5      nU R                  SU;   =(       a    SU;   [        U5      5        U R	                  [        U5      S[        U5      5        g)zGShould find two references and ignore a comment in a fenced code block.r   z```
a
b/
#comment
```r$   r%   r&   r'   Nr(   r+   s      r   2test_get_cell_reference_patterns_precode_mdcommentCTestBundlerTools.test_get_cell_reference_patterns_precode_mdcomment?   r0   r   c                     SSS.n[         R                  " U5      nU R                  SU;   =(       a    SU;   =(       a    SU;   [        U5      5        U R	                  [        U5      S[        U5      5        g)	z4Should find three references in a fenced code block.r   z```c
a
b/
#comment
```r$   r%   r&   r2   r3   Nr(   r+   s      r   2test_get_cell_reference_patterns_precode_backticksCTestBundlerTools.test_get_cell_reference_patterns_precode_backticksJ   r6   r   c                     U R                  [        R                  R                  SS5      [        R
                  " [        S/5      5        g)z9Should expand to single file in the resources/ subfolder.	resourcesempty.ipynbzresources/empty.ipynbNassertInospathjoinr   expand_referencesHEREr
   s    r   test_glob_dirTestBundlerTools.test_glob_dirU   s4    bggll;>##D+B*CD	Fr   c                     U R                  [        R                  R                  SS5      [        R
                  " [        S/5      5        g)z7Should expand to all files in the resources/ subfolder.rB   rC   z
resources/NrD   r
   s    r   test_glob_subdir!TestBundlerTools.test_glob_subdirZ   s1    bggll;>##D<.9	;r   c                     [         R                  " [        S/5      nU R                  SX5        U R                  SX5        g)z9Should expand to all contents under this test/ directory.*ztest_bundler_tools.pyrB   N)r   rI   rJ   rE   r   globss     r   test_glob_splat TestBundlerTools.test_glob_splat_   s3    ''se4-u<k50r   c                     [         R                  " [        S/5      nU R                  [        R
                  R                  SSS5      X5        g)z?Should expand to test_file.txt deep under this test/ directory.zresources/**/test_file.txtrB   subdirtest_file.txtNr   rI   rJ   rE   rF   rG   rH   rR   s     r   test_glob_splatsplat_in_middle/TestBundlerTools.test_glob_splatsplat_in_middlee   s7    ''/K.LMbggll;/JEYr   c                     [         R                  " [        S/5      nU R                  [        R
                  R                  SS5      X5        U R                  [        R
                  R                  SSS5      X5        g)z9Should expand to all descendants of this test/ directory.zresources/**rB   rC   rW   rX   NrY   rR   s     r   test_glob_splatsplat_trailing.TestBundlerTools.test_glob_splatsplat_trailingj   sS    ''~.>?bggll;>Mbggll;/JEYr   c                     [         R                  " [        S/5      nU R                  [        R
                  R                  SSS5      X5        U R                  [        R
                  R                  SSS5      X5        g)z.Should expand to test_file.txt under any path.**/test_file.txtrB   rW   rX   another_subdirNrY   rR   s     r   test_glob_splatsplat_leading-TestBundlerTools.test_glob_splatsplat_leadingp   sX    ''/A.BCbggll;/JEYbggll;0@/RTYar   c           
         [         R                  " [        S/5      n[         R                  " [        U R                  U5        U R                  [        R                  R                  [        R                  R                  U R                  SSS5      5      5        U R                  [        R                  R                  [        R                  R                  U R                  SSS5      5      5        U R                  [        R                  R                  [        R                  R                  U R                  SS5      5      5        g)z3Should copy select files from source to destinationr`   rB   rW   rX   ra   rC   N)r   rI   rJ   copy_filelistr	   r)   rF   rG   isfilerH   assertFalserR   s     r   test_copy_filelist#TestBundlerTools.test_copy_filelistv   s    ''/A.BCD$((E2rww||DHHk8Ud'efgrww||DHHkK[]l'mnoTXX{M(Z[\r   )r	   N)__name__
__module____qualname____firstlineno__r   r   r!   r.   r4   r9   r<   r?   rK   rN   rT   rZ   r]   rb   rh   __static_attributes__ r   r   r   r      sR    &40	>	>	0	>	>F
;
1Z
Zb]r   r   )__doc__unittestrF   r   r   nbclassic.bundler.toolsbundlerr   rG   abspathdirname__file__rJ   TestCaser   ro   r   r   <module>rx      sQ    
  	   ' '	wwrwwx01n]x(( n]r   