ó
‹²,]c           @   sA  d  Z  y d d l m Z Wn! e k
 r= d d l m Z n Xd d l Z d d l Z d d l m	 Z	 d d l
 m Z e j d „  ƒ Z e j j d d d	 d
 g ƒ d „  ƒ Z e j j d e e g ƒ d „  ƒ Z e j j d e e g ƒ d „  ƒ Z e j j d e e g ƒ d „  ƒ Z d „  Z e d k r=e j ƒ  n  d S(   s    
Tests for the Projects plugin.
iÿÿÿÿ(   t   MockN(   t   Projects(   t   to_text_stringc         C   s‹   d t  f d „  ƒ  Y} t d d ƒ } d | _ | j j  t j j d ƒ | j j  | d ƒ | j ƒ  | ƒ  | _	 |  j
 | ƒ | j ƒ  | S(   s   Projects plugin fixture.t   MainWindowMockc           B   s   e  Z d  „  Z RS(   c         S   s'   | d k s | d k r d  St ƒ  Sd  S(   Nt
   ipyconsolet   editor(   t   NoneR    (   t   selft   attr(    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt   __getattr__$   s    (   t   __name__t
   __module__R	   (    (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyR   #   s   t   parentt   install_tab_event_filtert   toggle_view_actionN(   t   objectR   R   t   shortcutt   patcht   spydert   pluginst   SpyderDockWidgett   create_dockwidgett   maint	   addWidgett   show(   t   qtbott   mockerR   t   projects(    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyR      s    	

t   test_directoryu   æ¸¬è©¦u   Ø§Ø®ØªØ¨Ø§Ø±u   test_dirc         C   sH   t  | j | ƒ ƒ } |  j d | ƒ |  j | ƒ s: t ‚ |  j ƒ  d S(   s7   Test that we can create a project in a given directory.t   pathN(   R   t   mkdirt   open_projectt   is_valid_projectt   AssertionErrort   close_project(   R   t   tmpdirR   R   (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt   test_open_project?   s    t   valuec         C   sp   |  j  d | ƒ |  j d t | ƒ ƒ | r: |  j ƒ  n |  j j ƒ  |  j ƒ  |  j d ƒ | k sl t ‚ d S(   sl   Test that when project is closed, the config option
    visible_if_project_open is set to the correct value.t   visible_if_project_openR   N(	   t
   set_optionR   R   t   show_explorert
   dockwidgett   closeR"   t
   get_optionR!   (   R   R#   R%   (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt&   test_close_project_sets_visible_configO   s    
c         C   s–   |  j  d | ƒ |  j ƒ  |  j d ƒ | k s7 t ‚ |  j d t | ƒ ƒ | r` |  j ƒ  n |  j j ƒ  |  j	 ƒ  |  j d ƒ | k s’ t ‚ d S(   s_   Test that closing_plugin() sets config option visible_if_project_open
    if a project is open.R&   R   N(
   R'   t   closing_pluginR+   R!   R   R   R(   R)   R*   R"   (   R   R#   R%   (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt'   test_closing_plugin_sets_visible_config_   s    

c         C   sE   |  j  d | ƒ |  j d t | ƒ ƒ |  j j ƒ  | k sA t ‚ d S(   s€   Test that when a project is opened, the project explorer is only opened
    if the config option visible_if_project_open is set.R&   R   N(   R'   R   R   R)   t	   isVisibleR!   (   R   R#   R%   (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt%   test_open_project_uses_visible_configr   s    c         C   s  t  |  j ƒ } t | j d ƒ ƒ } t | j d ƒ ƒ } t | j d ƒ ƒ } |  j d | ƒ |  j d | ƒ |  j d | ƒ t  |  j ƒ | d d k s¡ t ‚ |  j ƒ  j | k s¼ t ‚ |  j d j	 ƒ  |  j ƒ  j | k sè t ‚ |  j d j	 ƒ  |  j ƒ  j | k st ‚ d S(	   sž   
    Test that the actions of the submenu 'Recent Projects' in the 'Projects'
    main menu are working as expected.
    Regression test for Issue #8450.
    t   project0t   project1t   project2R   i   i   i   N(
   t   lent   recent_projectsR   R   R   t   recent_projects_actionsR!   t   get_active_projectt	   root_patht   trigger(   R   R#   t   recent_projects_lent   path0t   path1t   path2(    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt    test_recent_projects_menu_action{   s    t   __main__(   t   __doc__t   unittest.mockR    t   ImportErrort   mockt   pytestt   spyder.pluginsR   t   spyder.plugins.projectsR   t   spyder.py3compatR   t   fixtureR   t   markt   parametrizeR$   t   Truet   FalseR,   R.   R0   R>   R
   R   (    (    (    sA   lib/python2.7/site-packages/spyder/plugins/tests/test_projects.pyt   <module>   s     '$$$		