U
    yb$h                     @   s2   d dl T d dlT d dlmZ G dd dejZdS )    )*)cmf_testcase_runc                       s^   e Zd Zejjdg Zdd Zdd Zdd Z fdd	Z	d
d Z
 fddZdd Z  ZS )CmfTestcaseRunrunc                 O   sZ   |  ddg |  jd7  _tjjddidd| gd tj| | j| j| jd	| jd
| _d S )Ntestcaseresponsible   curFparent==)valuesfilterT)r
   Zcache_testcaser   cache_estimate_timer	   	iteration)	load_fieldsr   modelsZCmfTestcaseRunHistoryZbulk_updater   r   r   cur_historyselfargskwargs r   ,./modules/evatest/models/cmf_testcase_run.pyr      s    zCmfTestcaseRun.runc                 C   sJ   | j jsd S | j jr(| j j| j j8  _| j j| j j7  _| j  d S N)r   
is_changedoldr
   Zestimate_timenewsaver   r   r   r   _calc_estimate_time   s    z"CmfTestcaseRun._calc_estimate_timec                 C   s
  | j js| jr| jsd S | jj}| j jrD| j jrD|| j j  d8  < | j j|kr^d|| j j< n|| j j  d7  < || j_| jjdkr| j dkr| jjj	dd| j_ | jjdkr| j dkrt
jjdd	| jgd
ddgdd| jggd}|s| jjj	dd| j_ | j  d S )Nr   ZOPENopenZIN_PROGRESS)Zstatus_typeZCLOSED)r    Zin_progressr
   r   statusINidz!=)r   )r!   r   is_newr
   Ztestcase_run_cacher   r   Zcache_status_typeZworkflowZget_default_statusr   r   countr#   r   )r   Z	run_cacheZcntr   r   r   _cache_status%   s&    
zCmfTestcaseRun._cache_statusc              	      s   t   ddddddddg S )	Nztestcase.estimate_timezparent.statusr!   zparent.testcase_run_cachezparent.workflowzparent.cache_status_typecur_history.responsibler   )supersave_preload_fieldsr   	__class__r   r   r)   >   s       z"CmfTestcaseRun.save_preload_fieldsc                 C   s2   | j jr| j | jj krd S | j | j_ | j  d S r   )r   r   r   r   r   r   r   r   _calc_responsibleA   s    
z CmfTestcaseRun._calc_responsiblec                    sD   | j j| _|   |   | jr(|   | jr6|   t j	||S r   )
r   namer   r&   r   r,   r$   r   r(   r   r   r*   r   r   r   G   s    
zCmfTestcaseRun.savec                 C   sn   |  ddddddddd	g	 | js&d
S | jj| _| jj| _| jj| _| jj| _| jj| _| jj| _|   d
S )uC   Обновляем поля из текущего рана
        zcur_history.priorityzcur_history.statusr'   zcur_history.cmf_ownerzcur_history.test_configurationpriorityr   	cmf_ownertest_configurationN)	r   r   r.   r   r0   r/   r!   r-   r   r   r   r   r   recalc_fieldsW   s$        





zCmfTestcaseRun.recalc_fields)__name__
__module____qualname__r   r   Zapi_methodsr   r   r&   r)   r,   r   r1   __classcell__r   r   r*   r   r      s   r   N)Zcmf.includeZ
cmf.fieldsZmodules.evatest.fieldsr   r   r   r   r   r   <module>   s
   
