3
(h                 @   s8   d dl mZ ddlmZmZmZmZ G dd deZdS )    )BaseNestedAdminTestCase   )TopLevelLevelOneLevelTwo
LevelThreec                   sN   e Zd ZeZeeefZe	 fddZ
dd Zdd Zdd Zd	d
 Z  ZS )TestDeepNestingc                s$   t t| j  | j\| _| _| _d S )N)superr   
setUpClassnested_modelsl1_modell2_modell3_model)cls)	__class__ T/tmp/pip-install-q3hcpn_q/django-nested-admin/nested_admin/tests/three_deep/tests.pyr
   
   s    zTestDeepNesting.setUpClassc             C   sf   t jjdd}| j| | jddddgd | jdddddgd | j  | jjd}| j|d	 d S )
Na)namer   cr   )indexesdzIreturn $('ul.errorlist li').closest('.form-row').find('input').attr('id')zid_children-0-name)	r   objectscreate
load_admin	set_field	save_formZseleniumZexecute_scriptassertEqual)selftoplevelZfield_id_with_errorr   r   r   /test_validationerror_on_empty_extra_parent_form   s    
z?TestDeepNesting.test_validationerror_on_empty_extra_parent_formc       	      C   s  | j   | jdd | jdddg | jddddg | jdddddg | j  | jjj }| jt|dd| jj  | j	t|dd	| jj  |d }| j	|j
dd
| jj  |jj }| jt|dd| jj  | j	t|dd	| jj  |d }| j	|j
dd
| jj  |jj }| jt|dd| jj  | j	t|dd	| jj  |d }| j	|j
dd
| jj  |jj }| jt|dd| jj  | j	t|dd	| jj  |d }| j	|j
dd
| jj  d S )Nr   r   br   r   r   z%s did not saver   zToo many %s foundz%s.name has wrong value)r   r   r   
root_modelr   allassertNotEquallen__name__r   r   childrenr   r   r   )	r   root_instancesrootl1_instancesl1_instancel2_instancesl2_instancel3_instancesl3_instancer   r   r   test_create_new   s4    


zTestDeepNesting.test_create_newc       	      C   s  | j   | jdd | jdg | jdd | jddg | jdgdd | jdddg | jddgdd | j  | jjj }| jt	|dd| jj
  | jt	|d	d
| jj
  |d }| j|jdd| jj
  |jj }| jt	|dd| jj
  | jt	|d	d
| jj
  |d }| j|jdd| jj
  |jj }| jt	|dd| jj
  | jt	|d	d
| jj
  |d }| j|jdd| jj
  |jj }| jt	|dd| jj
  | jt	|d	d
| jj
  |d }| j|jdd| jj
  d S )Nr   r   r   r!   )r   r   r   z%s did not saver   zToo many %s foundz%s.name has wrong value)r   r   Zremove_inlineZ
add_inliner   r"   r   r#   r$   r%   r&   r   r   r'   r   r   r   )	r   r(   r)   r*   r+   r,   r-   r.   r/   r   r   r   test_create_new_no_extras:   s:    


z)TestDeepNesting.test_create_new_no_extrasc             C   sj   | j   | jdd | jdddg | jdddddg | j  | jjj }| jt|dd| jj  d S )Nr   r   r!   r   r   z%s did not save)	r   r   r   r"   r   r#   r$   r%   r&   )r   r(   r   r   r   %test_save_missing_intermediate_inlineZ   s    z5TestDeepNesting.test_save_missing_intermediate_inline)r&   
__module____qualname__r   r"   r   r   r   r   classmethodr
   r    r0   r1   r2   __classcell__r   r   )r   r   r      s   
 r   N)Znested_admin.tests.baser   modelsr   r   r   r   r   r   r   r   r   <module>   s   