
    Bh                         d dl mZmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
m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  G d de      Z G d de      Zy)    )Mockpatch)apps)ImproperlyConfigured)get_cms_config_appsget_cms_extension_apps)CMSCoreExtensions)cms_page_wizardcms_subpage_wizard)sample_wizard)CMSTestCase)setup_cms_apps)Wizardc                   $    e Zd Zd Zd Zd Zd Zy)ConfigureWizardsUnitTestCasec                     t               }t        dt              }t        dt              }t        d||g      }|j                  |       | j	                  |j
                  ||d       y)zr
        If the wizard setting is correctly defined, add the wizards to the
        dictionary of wizards
        o   idspec   Tcms_enabledcms_wizards)r   r   N)r	   r   r   configure_wizardsassertDictEqualwizards)self
extensionswizard1wizard2
cms_configs        Q/home/dcms/DCMS/lib/python3.12/site-packages/cms/tests/test_cms_config_wizards.pytest_adds_wizards_to_dictz6ConfigureWizardsUnitTestCase.test_adds_wizards_to_dict   sd    
 '(
#F+#F+7G*<>
$$Z0gG <	>    c                     t               }t        dg       }	 |j                  |       y# t        $ r | j	                  d       Y yw xY w)z
        If the wizard setting is not present in the config, simply
        ignore this. The wizard setting is optional.
        T)r   r   z+Raises exception when cms_wizards undefinedN)r	   r   configure_appAttributeErrorfail)r   r   r"   s      r#   7test_doesnt_raise_exception_when_wizards_dict_undefinedzTConfigureWizardsUnitTestCase.test_doesnt_raise_exception_when_wizards_dict_undefined   sJ    
 '(
d4
	E$$Z0 	EIICD	Es   + AAc                     t               }t        dt              }t        d|g      }|j                  |       | j	                  t
              5  |j                   ddd       y# 1 sw Y   yxY w)z
        If one or more of the wizards defined in the wizard setting
        do not inherit from the Wizard class, raise an exception
           r   Tr   N)r	   r   objectr   assertRaisesr   r   r   r   wizardr"   s       r#   9test_raises_exception_if_doesnt_inherit_from_wizard_classzVConfigureWizardsUnitTestCase.test_raises_exception_if_doesnt_inherit_from_wizard_class+   sd    
 '(
(6(4
$$Z034 		 	 	s   A&&A/c                     t               }t        dt              }t        d|      }| j                  t              5  |j                  |       ddd       y# 1 sw Y   yxY w)zK
        If the wizard setting isn't iterable, raise an exception.
           r   Tr   N)r	   r   r   r.   r   r   r/   s       r#   %test_raises_exception_if_not_iterablezBConfigureWizardsUnitTestCase.test_raises_exception_if_not_iterable9   sY     '(
(&2
34 	5((4	5 	5 	5s   AA"N)__name__
__module____qualname__r$   r*   r1   r4    r%   r#   r   r      s    >
E	5r%   r   c                       e Zd Zd Zd Zy)#ConfigureWizardsIntegrationTestCasec                 T    t        j                          t        j                          y )N)r   cache_clearr   )r   s    r#   setUpz)ConfigureWizardsIntegrationTestCase.setUpG   s    
 	**,'')r%   c                 
   t                t        j                  d      }t        j                  t        t
        j                  t
        t        j                  t        i}| j                  |j                  j                  |       y)zp
        Check that all wizards are picked up from both cms.cms_config
        and sampleapp.cms_config
        cmsN)
r   r   get_app_configr
   r   r   r   r   cms_extensionr   )r   appexpected_wizardss      r#   test_adds_all_wizards_to_dictzAConfigureWizardsIntegrationTestCase.test_adds_all_wizards_to_dictO   se    
 	!!%( !!#5m

 	S..668HIr%   N)r5   r6   r7   r=   rD   r8   r%   r#   r:   r:   E   s    *Jr%   r:   N)unittest.mockr   r   django.appsr   django.core.exceptionsr   cms.app_registrationr   r   cms.cms_configr	   cms.cms_wizardsr
   r   ,cms.test_utils.project.sampleapp.cms_wizardsr   cms.test_utils.testcasesr   cms.utils.setupr   cms.wizards.wizard_baser   r   r:   r8   r%   r#   <module>rO      s>    %  7 L , ? F 0 * *35; 35lJ+ Jr%   