ó
§‰]c           @   sl   d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l m	 Z	 d	 e f d
 „  ƒ  YZ
 d S(   s   Tests for HTMLExporteriÿÿÿÿNi   (   t   ExportersTestsBasei   (   t   HTMLExporter(   t   Config(   t   v4t   TestHTMLExporterc           B   sw   e  Z d  Z e Z d g Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   s   Tests for HTMLExportert   htmlc         C   s   t  ƒ  d S(   s4   
        Can a HTMLExporter be constructed?
        N(   R   (   t   self(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_constructor   s    c         C   s:   t  ƒ  j |  j ƒ  ƒ \ } } t | ƒ d k s6 t ‚ d S(   s6   
        Can a HTMLExporter export something?
        i    N(   R   t   from_filenamet   _get_notebookt   lent   AssertionError(   R   t   outputt	   resources(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_export   s    c         C   s@   t  d d ƒ j |  j ƒ  ƒ \ } } t | ƒ d k s< t ‚ d S(   sG   
        Can a HTMLExporter export using the 'basic' template?
        t   template_filet   basici    N(   R   R   R	   R
   R   (   R   R   R   (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_export_basic$   s    $c         C   s@   t  d d ƒ j |  j ƒ  ƒ \ } } t | ƒ d k s< t ‚ d S(   sF   
        Can a HTMLExporter export using the 'full' template?
        R   t   fulli    N(   R   R   R	   R
   R   (   R   R   R   (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_export_full,   s    $c         C   s”   t  d d ƒ j |  j d d ƒ ƒ \ } } d } d } d d d	 d	 d
 g } d g } t j | | ƒ | k sr t ‚ t j | | ƒ | k s t ‚ d S(   sM   
        Does HTMLExporter properly format input and output prompts?
        R   R   t   nb_names   prompt_numbers.ipynbs   In&nbsp;\[(.*)\]:s   Out\[(.*)\]:t   2t   10s   &nbsp;t   0N(   R   R   R	   t   ret   findallR   (   R   R   R   t   in_regext	   out_regext   inst   outs(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_prompt_number3   s    	c         C   s™   t  i i t d 6t d 6d 6ƒ } t d | d d ƒ } | j |  j d d ƒ ƒ \ } } d	 } d
 } t j | | ƒ s| t ‚ t j | | ƒ s• t ‚ d S(   sM   
        Does HTMLExporter properly format input and output prompts?
        t   exclude_input_promptt   exclude_output_promptt   TemplateExportert   configR   R   R   s   prompt_numbers.ipynbs   In&nbsp;\[(.*)\]:s   Out\[(.*)\]:N(   R   t   TrueR   R   R	   R   R   R   (   R   t   no_prompt_conft   exporterR   R   R   R   (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyR   B   s    c         C   s   t  d d ƒ j |  j d d ƒ ƒ \ } } t j d ƒ } | j | ƒ } | j d ƒ } d | k si t ‚ d | k s{ t ‚ d	 S(
   sn   
        Does HTMLExporter with the 'basic' template treat pngs with width/height metadata correctly?
        R   R   R   s   pngmetadata.ipynbs   <img src="[^"]*?"([^>]*?)>i   t   widtht   heightN(   R   R   R	   R   t   compilet   searcht   groupR   (   R   R   R   t   check_for_pngt   resultt   attr_string(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_png_metadataV   s    c         C   so   t  j d t  j d t  j d d d i d d 6ƒ g ƒ g ƒ } t d d	 ƒ j | ƒ \ } } |  j d
 | ƒ d  S(   Nt   cellst   outputst   output_typet   display_datat   datas   javascript_output();s   application/javascriptR   R   t   javascript_output(   R   t   new_notebookt   new_code_cellt
   new_outputR   t   from_notebook_nodet   assertIn(   R   t   nbR   R   (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_javascript_outputb   s    			c         C   sð   t  d d ƒ j |  j d d ƒ ƒ \ } } t j d ƒ } | j | ƒ } |  j | j d ƒ j ƒ  j	 d ƒ ƒ |  j | j d ƒ j ƒ  j	 d	 ƒ ƒ t j d
 ƒ } | j
 | ƒ } | d | d k sÐ t d ƒ ‚ d | d k sì t d ƒ ‚ d  S(   NR   R   R   s   attachment.ipynbs   <img src="[^"]*?"([^>]*?)>i    s%   <img src="data:image/png;base64,iVBORi   s   alt="image.png"s   <img src="(?P<url>[^"]*?)"s0   attachments only need to be unique within a cells	   image/svgs   second image should use svg(   R   t	   from_fileR	   R   R(   R)   t
   assertTrueR*   t   stript
   startswithR   R   (   R   R   R   R+   R,   t   check_for_datat   results(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   test_attachmentsr   s    %% c         C   s|   t  j ƒ  } | j j t  j d ƒ ƒ d d  d „ } i | d 6} t d d d | ƒ j | ƒ \ } } |  j d | k ƒ d  S(	   Nt	   some_textt   pythonc         S   s   |  d S(   Ns    ADDED_TEXT(    (   t   sourcet   languaget   metadata(    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   custom_highlight_code†   s    t   highlight_codeR   R   t   filterst
   ADDED_TEXT(	   R   R5   R/   t   appendR6   t   NoneR   R8   R=   (   R   R:   RH   RJ   R   R   (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt!   test_custom_filter_highlight_code   s    
$(   t   __name__t
   __module__t   __doc__R   t   exporter_classt   should_include_rawR   R   R   R   R   R.   R;   RB   RN   (    (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyR      s   										(   RQ   R   t   baseR    R   R   t   traitlets.configR   t   nbformatR   R   (    (    (    sB   lib/python2.7/site-packages/nbconvert/exporters/tests/test_html.pyt   <module>   s   