ó
¹9—^c           @   sš   d  d l  Z  d  d l Z d  d l m Z m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 d  d l m Z e e j d ƒ Z d e
 f d	 „  ƒ  YZ d S(
   iÿÿÿÿN(   t   patcht   Mock(   t   FlatPage(   t   HttpResponse(   t   TestCase(   t   render_to_image_listt   wt	   TestViewsc           B   s‰   e  Z e d  ƒ d „  ƒ Z e d  ƒ d „  ƒ Z e d  ƒ d „  ƒ Z d „  Z e d ƒ d „  ƒ Z d „  Z e d d	 d
 ƒd „  ƒ Z	 RS(   s   tinymce.views.enchantc         C   sã   t  ƒ  } t | j _ | | j _ t j i d d 6d d 6d d g g d 6ƒ } |  j j d | d d	 ƒ} i d d 6d g d
 6d  d 6} t
 t j | ƒ d d	 ƒ} |  j d | j ƒ |  j d	 | d ƒ |  j | j | j ƒ d  S(   Nt   testt   idt
   checkWordst   methodt   ent   paramss   /tinymce/spellchecker/t   content_types   application/jsont   resultt   erroriÈ   s   Content-Type(   R   t   Falset   checkt   return_valuet   Dictt   jsont   dumpst   clientt   postt   NoneR   t   assertEqualt   status_codet   content(   t   selft   enchant_mockt   checker_mockt   bodyt   responset   outputt   response_ok(    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_spell_check_words   s"    		

c         C   sæ   d g } t  ƒ  } | | j _ | | j _ t j i d d 6d d 6d d g d 6ƒ } |  j j d | d d	 ƒ} i d d 6| d
 6d  d 6} t	 t j | ƒ d d	 ƒ} |  j
 d | j ƒ |  j
 d	 | d ƒ |  j
 | j | j ƒ d  S(   NR   R	   t   getSuggestionsR   R   R   s   /tinymce/spellchecker/R   s   application/jsonR   R   iÈ   s   Content-Type(   R   t   suggestR   R   R   R   R   R   R   R   R   R   R   (   R   R   R   R   R    R!   R"   R#   (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_spell_check_suggest*   s$    			
c      	   C   sÃ   t  ƒ  } d g | j _ | | j _ t j i d d 6d d 6d d g d 6ƒ } t d t ƒ   |  j j	 d | d d	 ƒ} Wd  QXd
 } |  j
 d | j ƒ |  j
 d | d ƒ |  j
 | | j ƒ d  S(   NR   R	   R   R   R   s
   sys.stderrs   /tinymce/spellchecker/R   s   application/jsons   Error running spellcheckeriÈ   s   text/html; charset=utf-8s   Content-Type(   R   R&   R   R   R   R   R    t   devnullR   R   R   R   R   (   R   R   R   R    R!   t	   result_ok(    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_spell_check_unknownB   s    		c         C   so   t  j j d d d d ƒ |  j j d ƒ } d } |  j d | j ƒ |  j d | d	 ƒ |  j | | j ƒ d  S(
   Nt   urls	   /test/urlt   titles
   Test Titles   /tinymce/flatpages_link_list/s4   var tinyMCELinkList = [["Test Title", "/test/url"]];iÈ   s   application/x-javascripts   Content-Type(   R   t   objectst   createR   t   getR   R   R   (   R   R!   R)   (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_flatpages_link_listU   s    s   tinymce.views.gzip_compressorc         C   s~   t  d d d ƒ} | | _ |  j j d ƒ } |  j d | j ƒ |  j d | d ƒ |  j | j | j ƒ |  j | j ƒ d  S(   NR   R   s   text/javascripts   /tinymce/compressor/iÈ   s   Content-Type(	   R   R   R   R/   R   R   R   t
   assertTruet   called_once(   R   t	   gzip_mockR#   R!   (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_compressor`   s    	c         C   sS   t  d g ƒ } d } |  j d | j ƒ |  j d | d ƒ |  j | | j ƒ d  S(   NR   s   test.jpgs.   var tinyMCEImageList = [["test", "test.jpg"]];iÈ   s   application/x-javascripts   Content-Type(   R   s   test.jpg(   R   R   R   R   (   R   R!   R)   (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_render_to_image_listl   s
    s   tinymce.views.reverseR   s   /filebrowserc         C   sB   |  j  j d ƒ } d } |  j d | j ƒ |  j | | j ƒ d  S(   Ns   /tinymce/filebrowser/s2  function djangoFileBrowser(field_name, url, type, win) {
    var url = "http://testserver/filebrowser?pop=2&type=" + type;

    tinyMCE.activeEditor.windowManager.open(
        {
            'file': url,
            'width': 820,
            'height': 500,
            'resizable': "yes",
            'scrollbars': "yes",
            'inline': "no",
            'close_previous': "no"
        },
        {
            'window': win,
            'input': field_name,
            'editor_id': tinyMCE.selectedInstance.editorId
        }
    );
    return false;
}
iÈ   (   R   R/   R   R   R   (   R   t   reverse_mockR!   R#   (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   test_filebrowsers   s    (
   t   __name__t
   __module__R    R$   R'   R*   R0   R4   R5   R7   (    (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyR      s   		(   R   t   ost   mockR    R   t   django.contrib.flatpages.modelsR   t   django.httpR   t   django.testR   t   tinymce.viewsR   t   openR(   R   (    (    (    s:   /tmp/pip-unpacked-wheel-51oq52/tinymce/tests/test_views.pyt   <module>   s   