σ
mάJ]c           @` s  d  d l  m Z m Z m Z m Z d  d l Z e d  d l m Z d  d l m	 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  d	 l m Z d  d
 l m Z d  d l m Z m Z m Z d  d l m Z d  d l j j Z  d  d l m! Z! d   Z" e j# d    Z$ d e% f d     YZ& d e% f d     YZ' d e% f d     YZ( d e% f d     YZ) d e% f d     YZ* d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   patch(   t   OrderedDict(   t   Template(   t   string_types(   t   Document(   t   standalone_docs_json(   t   curdoc(   t   figure(   t   CDNt   JSResourcest   CSSResources(   t   encode_utf8(   t
   RenderRootc           C` s   d S(   Nu   ID(    (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt	   stable_id,   s    c          C` s9   d d l  m }  |    } | j d d g d d g  | S(   Ni    (   R   i   i   i   (   t   bokeh.plottingR   t   circle(   R   t	   test_plot(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR   /   s    	t   Test_autoload_staticc           B` s   e  Z d    Z d   Z RS(   c         C` s1   t  j | t d  } t |  d k s- t  d  S(   Nu	   some/pathi   (   t   best   autoload_staticR   t   lent   AssertionError(   t   selfR   t   r(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_return_type<   s    c         C` s’   t  j | t d  \ } } t j | d  } | j d d  } t |  d k sW t  | d j } t	 |  t	 d d g  k s t  | d d k s t  d  S(	   Nu	   some/pathu   lxmlt   nameu   scripti   i    u   srcu   id(
   R   R   R   t   bs4t   BeautifulSoupt   findAllR   R   t   attrst   set(   R   R   t   jst   tagt   htmlt   scriptsR!   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_script_attrs@   s    $(   t   __name__t
   __module__R   R'   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR   :   s   	t   Test_componentsc           B` se   e  Z d    Z e d d d   d    Z d   Z e d d e d    Z d   Z d	   Z	 RS(
   c         C` s  t    } | j g  g   t    } | j g  g   t   j |  t   j |  t j |  } t |  d k sy t  t j | | f  \ } } t | t	  s© t  t j | | g  \ } } t | t	  sΩ t  t j i | d 6| d 6 \ } } t | t
  st  t d   | j   D  s3t  t j t d | f d | f g   \ } } t | t  sut  t d   | j   D  st  d  S(   Ni   u   Plot 1u   Plot 2c         s` s   |  ] } t  | t  Vq d  S(   N(   t
   isinstanceR   (   t   .0t   x(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pys	   <genexpr>`   s    c         s` s   |  ] } t  | t  Vq d  S(   N(   R+   R   (   R,   R-   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pys	   <genexpr>d   s    (   R   R   R
   t   add_rootR   t
   componentsR   R   R+   t   tuplet   dictt   allt   keysR   (   R   t   plot1t   plot2R   t   _t   divs(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR   L   s$    		#"-u(   bokeh.embed.util.make_globally_unique_idt   new_callablec           C` s   t  S(   N(   R   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   <lambda>f   t    c         C` s2  t    } t   } | j g  g   | j |  t   } | j g  g   | j |  t d d d d  } t d d d d  } t j | d t \ } } | | k s¬ t  t j | | f d t \ } }	 |	 | | f k sε t  t j i | d 6| d 6d t \ } }
 |
 i | d 6| d 6k s.t  d  S(   Nt	   elementidu   IDt   idt   wrap_plot_infou   p1u   p2(	   R   R   R   R.   R   R   R/   t   FalseR   (   R   t   mock_make_idt   docR4   R5   t   expected_plotdict_1t   expected_plotdict_2R6   t   plotdictt   plotidst
   plotiddict(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt4   test_plot_dict_returned_when_wrap_plot_info_is_falsef   s    			!)c         C` su   t  j |  \ } } t j | d  } | j d d  } t |  d k sQ t  | d j i d d 6k sq t  d  S(   Nu   lxmlR   u   scripti   i    u   text/javascriptu   type(   R   R/   R   R   R    R   R   R!   (   R   R   t   scriptt   divR%   R&   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_result_attrs}   s
    t   newc         C` sο   t  j |  \ } } t j | d  } | j d d  } t |  d k sQ t  | d } t | j  t d d d g  k s t  | j d d	 g k s‘ t  | j d d
 k sΊ t  | j d | j	 k sΦ t  | j
 d k sλ t  d  S(   Nu   lxmlR   u   divi   i    u   classu   idu   data-root-idu   bk-rootu   IDu    (   R   R/   R   R   R    R   R   R"   R!   R<   t   text(   R   R   RG   RH   R%   R7   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_div_attrs   s    
*c         C` s.   t  j |  \ } } t | t  s* t  d  S(   N(   R   R/   R+   t   strR   (   R   R   RG   RH   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_script_is_utf8_encoded   s    c         C` sU   t  j |  \ } } t j | d  } | j d d  } t |  d k sQ t  d  S(   Nu   lxmlR   u   scripti   (   R   R/   R   R   R    R   R   (   R   R   RG   RH   R%   R&   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt;   test_output_is_without_script_tag_when_wrap_script_is_false   s    (
   R(   R)   R   R   RF   RI   R   RL   RN   RO   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR*   J   s   			t   Test_file_htmlc           B` sw   e  Z d    Z e d  d    Z e d  d    Z e d  d    Z e d  d    Z d   Z d   Z	 RS(   c         C` s·   d d d     Y} t  j | t d  } t | t  s= t  t  j | t d | |    } t | t  sp t  t  j | t d | |  d h  i d d 6 } t | t  s³ t  d  S(   Nt   fake_templatec           B` s   e  Z d d   Z d   Z RS(   c         S` sJ   | |  _  d d d d d d d h |  _ | d  k	 rF |  j j |  n  d  S(   Nu   titleu   bokeh_jsu	   bokeh_cssu   plot_scriptu   docu   docsu   base(   t   testert   template_variablest   Nonet   update(   R   RR   t   user_template_variables(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   __init__©   s    	c         S` s(   |  j  j t | j     s$ t  d S(   Nu   template result(   RS   t   issubsetR"   R3   R   (   R   RS   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   render·   s    $N(   R(   R)   RT   RW   RY   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyRQ   ¨   s   u   titleu   test_varu   test(    (   R   t	   file_htmlR   R+   RM   R   (   R   R   RQ   R   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR   ¦   s    u   bokeh.embed.bundle.warnc         C` sq   t  d d d d g  } t d  } t j | | d  f d d | } t d | j    } | | k sm t  d  S(	   Nt   modeu   relativeR/   u   bokehu(   <head>{{ bokeh_js }}</head><body></body>u   titlet   templateu   <head>%s</head><body></body>(   R   R   R   RZ   RT   R   t	   render_jsR   (   R   t	   mock_warnR   t   js_resourcesR\   t   outputR%   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt(   test_file_html_handles_js_only_resourcesΖ   s
    !c         C` s3   t    } t j | | d  f d  | j d  d  S(   Nu   titleu`   No Bokeh CSS Resources provided to template. If required you will need to provide them manually.(   R   R   RZ   RT   t   assert_called_once_with(   R   R^   R   R_   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt)   test_file_html_provides_warning_if_no_cssΞ   s    	c         C` sq   t  d d d d g  } t d  } t j | d  | f d d | } t d | j    } | | k sm t  d  S(	   NR[   u   relativeR/   u   bokehu)   <head>{{ bokeh_css }}</head><body></body>u   titleR\   u   <head>%s</head><body></body>(   R   R   R   RZ   RT   R   t
   render_cssR   (   R   R^   R   t   css_resourcesR\   R`   R%   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt)   test_file_html_handles_css_only_resourcesΦ   s
    !c         C` s3   t    } t j | d  | f d  | j d  d  S(   Nu   titleu_   No Bokeh JS Resources provided to template. If required you will need to provide them manually.(   R   R   RZ   RT   Rb   (   R   R^   R   Re   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt(   test_file_html_provides_warning_if_no_jsή   s    	c         C` s+   t  j | t d  } d | k s' t  d  S(   Nu   &<u   <title>&amp;&lt;</title>(   R   RZ   R   R   (   R   R   R   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_file_html_title_is_escapedζ   s    c         C` s   d d l  m } d d l m } t   } | j d g d g  | d d  } |   } | j |  | j |  t j | g t	  } d | k s t
  d  S(   Ni    (   R   (   t   Buttont   labelu   Buttonu   bokeh-widgets(   t   bokeh.documentR   t   bokeh.modelsRi   R   R-   R.   R   RZ   R   R   (   R   R   Ri   t   figt   buttont   dt   out(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_entire_doc_is_not_usedκ   s    		(
   R(   R)   R   R   Ra   Rc   Rf   Rg   Rh   Rq   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyRP   €   s   	 	t   Test_json_itemc           B` sJ   e  Z d    Z d   Z d   Z d   Z d   Z e d  d    Z RS(   c         C` s/   t  j | d d } | d d k s+ t  d  S(   Nt   targetu   foou	   target_id(   R   t	   json_itemR   (   R   R   Rp   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_with_target_idύ   s    c         C` s)   t  j |  } | d d  k s% t  d  S(   Nu	   target_id(   R   Rt   RT   R   (   R   R   Rp   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_without_target_id  s    c         C` sN   t  j | d d } t t | g  j    d } | d | k sJ t  d  S(   NRs   u   fooi    u   doc(   R   Rt   t   listR	   t   valuesR   (   R   R   Rp   t   expected(    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_doc_json  s    c         C` s3   t  j | d d } | d d d k s/ t  d  S(   NRs   u   foou   docu   titleu    (   R   Rt   R   (   R   R   Rp   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_doc_title
  s    c         C` s?   t  j | d d } | d d d d | d k s; t  d  S(   NRs   u   foou   docu   rootsu   root_idsi    u   root_id(   R   Rt   R   (   R   R   Rp   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_root_id  s    u(   bokeh.embed.standalone.OutputDocumentForc         C` sE   y t  j | d d Wn t k
 r* n X| j | g d d d  S(   Nt   themeu   foot   apply_theme(   R   Rt   t
   ValueErrorRb   (   R   t   mock_OFDR   (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   test_apply_theme  s
    (	   R(   R)   Ru   Rv   Rz   R{   R|   R   R   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyRr   ϋ   s   					t   Test__title_from_modelsc           B` s   e  Z RS(    (   R(   R)   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyR   &  s   (+   t
   __future__R    R   R   R   t   pytestt   mockR   t   collectionsR   R   t   jinja2R   t   sixR   Rk   R   t   bokeh.embed.utilR	   t   bokeh.ioR
   R   R   t   bokeh.resourcesR   R   R   t   bokeh.util.stringR   t   bokeh.embed.standalonet   embedt
   standaloneR   R   R   t   fixtureR   t   objectR   R*   RP   Rr   R   (    (    (    s@   lib/python2.7/site-packages/bokeh/embed/tests/test_standalone.pyt   <module>   s,   " 	ZW+