o
    i                     @   s`   d Z ddlZddlZddlZddlZddlm  mZ ej	ej
eZG dd dejZdS )zTest the bundler tools.    Nc                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd ZdS ) TestBundlerToolsc                 C   s   t  | _d S )N)tempfilemkdtemptmpself r   e/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclassic/bundler/tests/test_bundler_tools.pysetUp   s   zTestBundlerTools.setUpc                 C   s   t j| jdd d S )NT)ignore_errors)shutilrmtreer   r   r   r   r	   tearDown   s   zTestBundlerTools.tearDownc                 C   s$   t ddd}| t|d dS )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_referencesr   r   r	   test_get_no_cell_references   s   z,TestBundlerTools.test_get_no_cell_referencesc                 C   J   ddd}t |}| d|v od|v t| | t|dt| dS )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
referencesr   r   r	   2test_get_cell_reference_patterns_comment_multiline      

zCTestBundlerTools.test_get_cell_reference_patterns_comment_multilinec                 C   R   ddd}t |}| d|v od|v od|v t| | t|dt| dS )	z4Should find three references within an HTML comment.r   z!<!--associate:c
a
b/
#comment
-->r   r   r   c   Nr   r"   r   r   r	   :test_get_cell_reference_patterns_comment_trailing_filename)      

$zKTestBundlerTools.test_get_cell_reference_patterns_comment_trailing_filenamec                 C   s0   |  tj tddd}| t|d dS )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   r   r   r	   (test_get_cell_reference_patterns_precode4   s
   z9TestBundlerTools.test_get_cell_reference_patterns_precodec                 C   r   )zGShould find two references and ignore a comment in a fenced code block.r   z```
a
b/
#comment
```r   r   r   r   Nr   r"   r   r   r	   2test_get_cell_reference_patterns_precode_mdcomment?   r&   zCTestBundlerTools.test_get_cell_reference_patterns_precode_mdcommentc                 C   r'   )	z4Should find three references in a fenced code block.r   z```c
a
b/
#comment
```r   r   r   r(   r)   Nr   r"   r   r   r	   2test_get_cell_reference_patterns_precode_backticksJ   r+   zCTestBundlerTools.test_get_cell_reference_patterns_precode_backticksc                 C   $   |  tjddttdg dS )z9Should expand to single file in the resources/ subfolder.	resourcesempty.ipynbzresources/empty.ipynbNassertInospathjoinr   expand_referencesHEREr   r   r   r	   test_glob_dirU      zTestBundlerTools.test_glob_dirc                 C   r0   )z7Should expand to all files in the resources/ subfolder.r1   r2   z
resources/Nr3   r   r   r   r	   test_glob_subdirZ   r;   z!TestBundlerTools.test_glob_subdirc                 C   s.   t tdg}| d|| | d|| dS )z9Should expand to all contents under this test/ directory.*ztest_bundler_tools.pyr1   N)r   r8   r9   r4   r   globsr   r   r	   test_glob_splat_   s   z TestBundlerTools.test_glob_splatc                 C   s,   t tdg}| tjddd|| dS )z?Should expand to test_file.txt deep under this test/ directory.zresources/**/test_file.txtr1   subdirtest_file.txtNr   r8   r9   r4   r5   r6   r7   r>   r   r   r	   test_glob_splatsplat_in_middlee   s   z/TestBundlerTools.test_glob_splatsplat_in_middlec                 C   sD   t tdg}| tjdd|| | tjddd|| dS )z9Should expand to all descendants of this test/ directory.zresources/**r1   r2   rA   rB   NrC   r>   r   r   r	   test_glob_splatsplat_trailingj   s   z.TestBundlerTools.test_glob_splatsplat_trailingc                 C   sF   t tdg}| tjddd|| | tjddd|| dS )z.Should expand to test_file.txt under any path.**/test_file.txtr1   rA   rB   another_subdirNrC   r>   r   r   r	   test_glob_splatsplat_leadingp   s   z-TestBundlerTools.test_glob_splatsplat_leadingc              
   C   s   t tdg}t t| j| | tjtj	| jddd | tjtj	| jddd | 
tjtj	| jdd dS )z3Should copy select files from source to destinationrF   r1   rA   rB   rG   r2   N)r   r8   r9   copy_filelistr   r    r5   r6   isfiler7   assertFalser>   r   r   r	   test_copy_filelistv   s
   ""$z#TestBundlerTools.test_copy_filelistN)__name__
__module____qualname__r
   r   r   r%   r*   r-   r.   r/   r:   r<   r@   rD   rE   rH   rL   r   r   r   r	   r      s     	r   )__doc__unittestr5   r   r   nbclassic.bundler.toolsbundlerr   r6   abspathdirname__file__r9   TestCaser   r   r   r   r	   <module>   s    