o
    h                     @   s\   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mZ G dd deZdS )	    )apps)checks)models)TestCase)DraftStateMixinLockableMixinRevisionMixinWorkflowMixinc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestWorkflowMixinc              	   C   sB   dD ]}zdD ]}t j| |= qW q ty   Y qw t   d S )N)wagtailcorezwagtail.tests)workflowwithoutrevisionmodelworkflowwithoutdraftstatemodelworkflowincorrectordermodel1workflowincorrectordermodel2correctworkflowmodelcorrectnotlockableworkflowmodel)r   
all_modelsKeyErrorclear_cache)selfpackagemodel r   a/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/tests/test_workflow_model.pytearDown
   s   	zTestWorkflowMixin.tearDownc              	   C   s   t jdddd}G dd dttj}G dd dtttj}||fD ]$}| j|d	 ||_| |	 |g W d    n1 s@w   Y  q!d S )
NIWorkflowMixin requires DraftStateMixin and RevisionMixin (in that order).fMake sure your model's inheritance order is as follows: WorkflowMixin, DraftStateMixin, RevisionMixin.wagtailcore.E006hintidc                   @      e Zd ZdS )zbTestWorkflowMixin.test_missing_revision_or_draftstate_mixins.<locals>.WorkflowWithoutRevisionModelN__name__
__module____qualname__r   r   r   r   WorkflowWithoutRevisionModel'   s    r&   c                   @   r!   )zdTestWorkflowMixin.test_missing_revision_or_draftstate_mixins.<locals>.WorkflowWithoutDraftStateModelNr"   r   r   r   r   WorkflowWithoutDraftStateModel*       r'   r   )
r   Errorr	   r   Modelr   subTestobjassertEqualcheck)r   errorr&   r'   r   r   r   r   *test_missing_revision_or_draftstate_mixins   s    	
z<TestWorkflowMixin.test_missing_revision_or_draftstate_mixinsc              	   C   s   t jdddd}G dd dtttttj}G dd dttttj}||fD ]$}| j|d	 ||_	| 
| |g W d    n1 sDw   Y  q%d S )
Nr   r   r   r   c                   @   r!   )zSTestWorkflowMixin.test_incorrect_mixins_order.<locals>.WorkflowIncorrectOrderModel1Nr"   r   r   r   r   WorkflowIncorrectOrderModel1>   r(   r2   c                   @   r!   )zSTestWorkflowMixin.test_incorrect_mixins_order.<locals>.WorkflowIncorrectOrderModel2Nr"   r   r   r   r   WorkflowIncorrectOrderModel2C   r(   r3   r)   )r   r*   r   r	   r   r   r   r+   r,   r-   r.   r/   )r   r0   r2   r3   r   r   r   r   test_incorrect_mixins_order4   s$   
	

z-TestWorkflowMixin.test_incorrect_mixins_orderc              	   C   s   G dd dt ttttj}G dd dt tttj}||fD ] }| j|d | | g  W d    n1 s8w   Y  qd S )Nc                   @   r!   )zITestWorkflowMixin.test_correct_mixins_order.<locals>.CorrectWorkflowModelNr"   r   r   r   r   CorrectWorkflowModelN   r(   r5   c                   @   r!   )zTTestWorkflowMixin.test_correct_mixins_order.<locals>.CorrectNotLockableWorkflowModelNr"   r   r   r   r   CorrectNotLockableWorkflowModelS   r(   r6   r)   )	r	   r   r   r   r   r+   r,   r.   r/   )r   r5   r6   r   r   r   r   test_correct_mixins_orderM   s   


z+TestWorkflowMixin.test_correct_mixins_orderN)r#   r$   r%   r   r1   r4   r7   r   r   r   r   r
   	   s
    r
   N)django.appsr   django.corer   	django.dbr   django.testr   wagtail.modelsr   r   r   r	   r
   r   r   r   r   <module>   s    