
    ^h                     t    S r SSKrSSKJr  SSKJr  SSKJr  SSK	J
r
JrJrJr  SSKJr  S r " S	 S
\5      rg)zTest the bundlers API.    N)join)NotebookTestBase)write)new_notebooknew_markdown_cellnew_code_cell
new_output)patchc                 ,    U R                  US   5        g)z*Bundler test stub. Echo the notebook path.pathN)finish)handlermodels     b/home/james-whalen/.local/lib/python3.13/site-packages/nbclassic/bundler/tests/test_bundler_api.pybundler      s    NN5=!    c                   T   ^  \ rS rSrSr\U 4S j5       rS rS rS r	S r
S rS	rU =r$ )
BundleAPITest   z!Test the bundlers web service APIc                   > [         [        U ]  5         U R                  n[	        5       nUR
                  R                  [        S5      5        [        SS9nUR                  R                  [        SSS95        UR
                  R                  U5        [        R                  " [        US5      SS	S
9 n[        X$SS9  SSS5        g! , (       d  f       g= f)zlMake a test nbclassic. Borrowed from nbconvert test. Assumes the class
teardown will clean it up in the end.zCreated by testz
print(2*6))sourcestream12)output_typetexttestnb.ipynbwzutf-8)encoding   )versionN)superr   setup_classnotebook_dirr   cellsappendr   r   outputsr	   ioopenpjoinr   )clsnbdirnbcc1f	__class__s        r   r"   BundleAPITest.setup_class   s     	mS-/  ^
)*<=>=1:(GH
WWU5.13%'*+"#' ' 's   5C		
Cc                     U R                  SS5      nU R                  UR                  S5        U R                  SUR                  5        g)z7Should respond with 400 error about missing bundler argGETbundle/fake.ipynb  zMissing argument bundlerNrequestassertEqualstatus_codeassertInr   selfresps     r   test_missing_bundler_arg&BundleAPITest.test_missing_bundler_arg*   s<    ||E#67))3/0$))<r   c                     U R                  SSSS0S9nU R                  UR                  S5        U R                  SUR                  5        g)	z4Should respond with 404 error about missing notebookr2   r3   bundlerfake_bundlerparamsi  z	Not FoundNr5   r:   s     r   test_notebook_not_found%BundleAPITest.test_notebook_not_found0   sJ    ||E#6~.  0))3/k499-r   c                     U R                  SSSS0S9nU R                  UR                  S5        U R                  SUR                  5        g)	z4Should respond with 400 error about disabled bundlerr2   bundle/testnb.ipynbr@   rA   rB   r4   z Bundler fake_bundler not enabledNr5   r:   s     r   test_bundler_not_enabled&BundleAPITest.test_bundler_not_enabled7   sK    ||E#8~.  0))3/8$))Dr   c                    [        S5       nSS0Ul        U R                  SSSS0S9nUR                  S5        S	S	S	5        U R	                  WR
                  S
5        U R                  SUR                  5        g	! , (       d  f       NG= f)zBShould respond with 500 error about failure to load bundler module5nbclassic.bundler.handlers.BundlerHandler.get_bundlermodule_namefake_moduler2   rG   r@   rA   rB   Ni  z%Could not import bundler fake_bundlerr
   return_valuer6   assert_called_withr7   r8   r9   r   r;   mockr<   s      r   test_bundler_import_error'BundleAPITest.test_bundler_import_error>   s    JKt!. >D<<'<!>2   4D##N3	 L
 	))3/=tyyI LK   .A;;
B	c                    [        S5       nSS0Ul        U R                  SSSS0S9nUR                  S5        S	S	S	5        U R	                  WR
                  S
5        U R                  SUR                  5        g	! , (       d  f       NG= f)z9Should respond with 200 and output from test bundler stubrK   rL   z(nbclassic.bundler.tests.test_bundler_apir2   rG   r@   stub_bundlerrB   N   r   rN   rQ   s      r   test_bundler_invoke!BundleAPITest.test_bundler_invokeH   s    JKt!.0Z [D<<'<!>2   4D##N3	 L
 	))3/ndii0 LKrU    )__name__
__module____qualname____firstlineno____doc__classmethodr"   r=   rD   rH   rS   rY   __static_attributes____classcell__)r/   s   @r   r   r      s8    +$ $"=.EJ1 1r   r   )r`   r'   os.pathr   r)   nbclassic.tests.launchnotebookr   nbformatr   nbformat.v4r   r   r   r	   unittest.mockr
   r   r   r[   r   r   <module>ri      s7    
 
 ! ;    ":1$ :1r   