o
    h                     @   sD  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	 d dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZ G d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd  d eZ#d!S )"    )partial)TestCase)
SafeString)compare)StreamValue)get_image_model)get_test_image_file)	AdvertWithCustomPrimaryKeyEventCategory	EventPageEventPageSpeakerHeadCountRelatedModelUsingPK
SimplePage'SnippetChooserModelWithCustomPrimaryKey
StreamPage
TaggedPagec                   @   *   e Zd ZejZdd Zdd Zdd ZdS )TestFieldComparisonc                 C   s|   |  tjdtddtdd}| |j | |j | |	 d | |
 d | |
 t | |  d S )NcontentContentr   )comparison_classr   _meta	get_field
assertTrueis_fieldassertFalseis_child_relationassertEqualfield_labelhtmldiffassertIsInstancer   has_changedself
comparison r&   `/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/admin/tests/test_compare.pytest_hasnt_changed      
z&TestFieldComparison.test_hasnt_changedc                 C   T   |  tjdtddtdd}| | d | | t | |	  d S )Nr   Original contentr   Modified contentz\<span class="deletion">Original content</span><span class="addition">Modified content</span>
r   r   r   r   r   r    r!   r   r   r"   r#   r&   r&   r'   test_has_changed(      
z$TestFieldComparison.test_has_changedc                 C   F   |  tjdtddtdd}| | d | | t d S )Nr   r+   r   9<script type="text/javascript">doSomethingBad();</script>z<span class="deletion">Original content</span><span class="addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span>r   r   r   r   r   r    r!   r   r#   r&   r&   r'   test_htmldiff_escapes_value6   s   
z/TestFieldComparison.test_htmldiff_escapes_valueN)	__name__
__module____qualname__r   FieldComparisonr   r(   r.   r3   r&   r&   r&   r'   r      s
    r   c                   @   r   )TestTextFieldComparisonc                 C   r*   Nr   r+   r   r,   T<span class="deletion">Original</span><span class="addition">Modified</span> contentr-   r#   r&   r&   r'   r.   K   r/   z(TestTextFieldComparison.test_has_changedc                 C   T   |  tjdtd dtdd}| | d | | t | |	  d S )Nr   r   zAdded contentz+<span class="addition">Added content</span>r-   r#   r&   r&   r'   +test_from_none_to_value_only_shows_additionY      
zCTestTextFieldComparison.test_from_none_to_value_only_shows_additionc                 C   T   |  tjdtddtd d}| | d | | t | |	  d S )Nr   zRemoved contentr   z-<span class="deletion">Removed content</span>r-   r#   r&   r&   r'   +test_from_value_to_none_only_shows_deletionf   r=   zCTestTextFieldComparison.test_from_value_to_none_only_shows_deletionN)	r4   r5   r6   r   TextFieldComparisonr   r.   r<   r?   r&   r&   r&   r'   r8   F   s
    r8   c                   @   r   )TestRichTextFieldComparisonc                 C   r*   r9   r-   r#   r&   r&   r'   r.   y   r/   z,TestRichTextFieldComparison.test_has_changedc                 C   r*   )Nr   <b>Original</b> contentr   Modified <i>content</i>r:   r-   r#   r&   r&   r'   test_has_changed_html   r/   z1TestRichTextFieldComparison.test_has_changed_htmlc                 C   r0   )Nr   r+   r   zLDo something good. <script type="text/javascript">doSomethingBad();</script>z^<span class="deletion">Original content</span><span class="addition">Do something good.</span>r2   r#   r&   r&   r'   r3      s   
z7TestRichTextFieldComparison.test_htmldiff_escapes_valueN)	r4   r5   r6   r   RichTextFieldComparisonr   r.   rD   r3   r&   r&   r&   r'   rA   t   s
    rA   c                   @   s   e Zd ZejZdd Zdd Zdd Zdd Z	d	d
 Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)S )*TestStreamFieldComparisonc                 C   s   t jd}| |t t|jdgdt t|jdgd}| |j | |j	 | 
| d | 
| d | | t | |  d S )Nbodytextr   1rG   Bodyz3<div class="comparison__child-object">Content</div>)r   r   r   r   r   stream_blockr   r   r   r   r   r   r    r!   r   r"   r$   fieldr%   r&   r&   r'   r(      s4   z,TestStreamFieldComparison.test_hasnt_changedc                 C   l   t jd}| |t t|jdgdt t|jdgd}| | d | | t	 | 
|  d S )NrG   )rI   r+   rJ   rK   )rI   r,   rJ   <div class="comparison__child-object"><span class="deletion">Original</span><span class="addition">Modified</span> content</div>r   r   r   r   r   rM   r   r    r!   r   r   r"   rN   r&   r&   r'   r.      0   z*TestStreamFieldComparison.test_has_changedc              	   C   sn   t jd}| |t t|jdgdt t|jddgd}| | d | | t	 | 
|  d S )NrG   rH   rK   )rI   zNew Content2zt<div class="comparison__child-object">Content</div>
<div class="comparison__child-object addition">New Content</div>rR   rN   r&   r&   r'   test_add_block   s2   z(TestStreamFieldComparison.test_add_blockc              	   C   sp   t jd}| |t t|jg ddt t|jddgd}| | d | | t	 | 
|  d S )NrG   rH   )rI   zContent FoorT   rI   zContent Bar3rK   rH   rW   z<div class="comparison__child-object">Content</div>
<div class="comparison__child-object deletion">Content Foo</div>
<div class="comparison__child-object">Content Bar</div>rR   rN   r&   r&   r'   test_delete_block  s0   
z+TestStreamFieldComparison.test_delete_blockc              	   C   sp   t jd}| |t t|jg ddt t|jg dd}| | d | | t	 | 
|  d S )NrG   rV   rK   )rH   )rI   zContent BazrT   rW   z<div class="comparison__child-object">Content</div>
<div class="comparison__child-object">Content <span class="deletion">Foo</span><span class="addition">Baz</span></div>
<div class="comparison__child-object">Content Bar</div>rR   rN   r&   r&   r'   test_edit_block(  s,   
z)TestStreamFieldComparison.test_edit_blockc                 C   rP   )NrG   )	rich_textrB   rJ   rK   )r[   rC   rJ   rQ   rR   rN   r&   r&   r'   test_has_changed_richtextJ  rS   z3TestStreamFieldComparison.test_has_changed_richtextc                 C   ^   t jd}| |t t|jdgdt t|jdgd}| | d | | t	 d S )NrG   )rI   z/I <b>really</b> like original<i>ish</i> contentrJ   rK   )rI   zXI <b>really</b> like evil code <script type="text/javascript">doSomethingBad();</script>rJ   a  <div class="comparison__child-object">I &lt;b&gt;really&lt;/b&gt; like <span class="deletion">original&lt;i&gt;ish&lt;/i&gt; content</span><span class="addition">evil code &lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span></div>
r   r   r   r   r   rM   r   r    r!   r   rN   r&   r&   r'   %test_htmldiff_escapes_value_on_changeh  s.   z?TestStreamFieldComparison.test_htmldiff_escapes_value_on_changec              	   C   `   t jd}| |t t|jdgdt t|jddgd}| | d | | t	 d S )NrG   rI   'Original <em>and unchanged</em> contentrJ   rK   rI   r1   rT   <div class="comparison__child-object">Original &lt;em&gt;and unchanged&lt;/em&gt; content</div>
<div class="comparison__child-object addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</div>r^   rN   r&   r&   r'   'test_htmldiff_escapes_value_on_addition  0   zATestStreamFieldComparison.test_htmldiff_escapes_value_on_additionc                 C   `   t jd}| |t t|jddgdt t|jdgd}| | d | | t	 d S )NrG   ra   rc   rK   <div class="comparison__child-object">Original &lt;em&gt;and unchanged&lt;/em&gt; content</div>
<div class="comparison__child-object deletion">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</div>r^   rN   r&   r&   r'   'test_htmldiff_escapes_value_on_deletion  0   zATestStreamFieldComparison.test_htmldiff_escapes_value_on_deletionc                 C   r]   )NrG   )r[   z"I <b>really</b> like Wagtail &lt;3rJ   rK   )r[   bI <b>really</b> like evil code &gt;_&lt; <script type="text/javascript">doSomethingBad();</script>rJ   z<div class="comparison__child-object">I really like <span class="deletion">Wagtail &lt;3</span><span class="addition">evil code &gt;_&lt;</span></div>r^   rN   r&   r&   r'   ,test_htmldiff_richtext_strips_tags_on_change  s.   zFTestStreamFieldComparison.test_htmldiff_richtext_strips_tags_on_changec              	   C   r`   )NrG   r[   rb   rJ   rK   r[   rk   rT   z<div class="comparison__child-object">Original and unchanged content</div>
<div class="comparison__child-object addition">I really like evil code &gt;_&lt;</div>r^   rN   r&   r&   r'   .test_htmldiff_richtext_strips_tags_on_addition  rf   zHTestStreamFieldComparison.test_htmldiff_richtext_strips_tags_on_additionc                 C   rg   )NrG   rm   rn   rK   z<div class="comparison__child-object">Original and unchanged content</div>
<div class="comparison__child-object deletion">I really like evil code &gt;_&lt;</div>r^   rN   r&   r&   r'   .test_htmldiff_richtext_strips_tags_on_deletion  rj   zHTestStreamFieldComparison.test_htmldiff_richtext_strips_tags_on_deletionc                 C   r]   )NrG   )raw_htmlzOriginal<i>ish</i> contentrJ   rK   )rq   r1   rJ   z<div class="comparison__child-object"><span class="deletion">Original&lt;i&gt;ish&lt;/i&gt; content</span><span class="addition">&lt;script type=&quot;text/javascript&quot;&gt;doSomethingBad();&lt;/script&gt;</span></div>r^   rN   r&   r&   r'   .test_htmldiff_raw_html_escapes_value_on_change6  s.   zHTestStreamFieldComparison.test_htmldiff_raw_html_escapes_value_on_changec              	   C   r`   )NrG   rq   rb   rJ   rK   rq   r1   rT   rd   r^   rN   r&   r&   r'   0test_htmldiff_raw_html_escapes_value_on_additionV  s0   zJTestStreamFieldComparison.test_htmldiff_raw_html_escapes_value_on_additionc                 C   rg   )NrG   rs   rt   rK   rh   r^   rN   r&   r&   r'   0test_htmldiff_raw_html_escapes_value_on_deletionw  s0   zJTestStreamFieldComparison.test_htmldiff_raw_html_escapes_value_on_deletionc                 C   s   t jd}| |t t|jdddddfgdt t|jdddddfgd}d	}| | | | | t	 | 
|  d S )
NrG   productza packet of rolos75p)namepricerJ   rK   85pa  
            <div class="comparison__child-object"><dl>
                <dt>Name</dt>
                <dd>a packet of rolos</dd>
                <dt>Price</dt>
                <dd><span class="deletion">75p</span><span class="addition">85p</span></dd>
            </dl></div>
        )r   r   r   r   r   rM   assertHTMLEqualr    r!   r   r   r"   )r$   rO   r%   expectedr&   r&   r'   test_compare_structblock  s,   z2TestStreamFieldComparison.test_compare_structblockc              
   C   s   t jd}|jjd }|ddddddddg}|dd	dddd
ddg}| |t t|jd|dfgdt t|jd|dfgd}| }d}| 	|| | 
|t | |  d S )NrG   
title_listitemfooz$11111111-1111-1111-1111-111111111111)typevalueidbarz$22222222-2222-2222-2222-222222222222bardfoodrJ   rK   a  
            <div class="comparison__child-object">
                <div class="comparison__child-object">
                    <span class="deletion">bar</span>
                    <span class="addition">bard</span>
                </div>

                <div class="comparison__child-object">
                    <span class="deletion">foo</span>
                    <span class="addition">food</span>
                </div>
            </div>
        )r   r   r   rM   child_blocks	to_pythonr   r   r    r|   r!   r   r   r"   )r$   rO   block	block_valblock_val_2r%   r    r}   r&   r&   r'   test_compare_listblock  s\   z0TestStreamFieldComparison.test_compare_listblockc                 C   s  t jd}|jjd }d}d}d}ddgddg|fddgg d|fg d	d
dg|fg}|D ]Z\}}}	| j||dF ||}
||}| |t t|jd|
dfgdt t|jd|dfgd}|	 }| 
||	 | |t | |  W d    n1 sw   Y  q.d S )NrG   r   z
            <div class="comparison__child-object">
                <div class="comparison__child-object">foo</div>

                <div class="comparison__child-object">bar</div>
            </div>
        a  
            <div class="comparison__child-object">
                <div class="comparison__child-object">
                    foo
                </div>

                <div class="comparison__child-object">
                    <span class="deletion">bar</span>
                    <span class="addition">bap</span>
                </div>

                <div class="comparison__child-object addition">baz</div>
            </div>
        a  
            <div class="comparison__child-object">
                <div class="comparison__child-object">
                    <span class="deletion">foo</span>
                    <span class="addition">fo</span>
                </div>

                <div class="comparison__child-object">bar</div>

                <div class="comparison__child-object deletion">baz</div>
            </div>
        r   r   )r   bapbaz)r   r   r   fo)list_1list_2rJ   rK   )r   r   r   rM   r   subTestr   r   r   r    r|   r!   r   r   r"   )r$   rO   r   no_diffedit_and_add_diffedit_and_add_diff_reversedold_format_listblock_fixturesr   r   expected_diffr   r   r%   r    r&   r&   r'   !test_compare_listblock_old_format  sJ   

z;TestStreamFieldComparison.test_compare_listblock_old_formatc                 C   s   t jd}|jjd }| |t t|jdt|dgdfgdt t|jdt|dgdfgd}d}| | | | 	| t
 | |  d S )NrG   books)titlezThe Old Man and the Sea10rJ   rK   )authorzOscar Wilde11z
            <div class="comparison__child-object">
                <div class="comparison__child-object addition">Oscar Wilde</div>

                <div class="comparison__child-object deletion">The Old Man and the Sea</div>
            </div>
        )r   r   r   rM   r   r   r   r|   r    r!   r   r   r"   )r$   rO   rM   r%   r}   r&   r&   r'   5test_compare_nested_streamblock_uses_comparison_classD  sD    zOTestStreamFieldComparison.test_compare_nested_streamblock_uses_comparison_classc              
   C   s   t  }|jjdt d}|jjdt d}tjd}| |tt|j	d|dfgdtt|j	d|dfgd}|
 }| d| | d	| | d
| | d| | |t | |  d S )NTest image 1r   fileTest image 2rG   imagerJ   rK   z$<div class="preview-image deletion">zalt="Test image 1"z$<div class="preview-image addition">zalt="Test image 2")r   objectscreater   r   r   r   r   r   rM   r    assertInr!   r   r   r"   )r$   image_modeltest_image_1test_image_2rO   r%   resultr&   r&   r'   test_compare_imagechooserblockq  sD   z8TestStreamFieldComparison.test_compare_imagechooserblockN)r4   r5   r6   r   StreamFieldComparisonr   r(   r.   rU   rY   rZ   r\   r_   re   ri   rl   ro   rp   rr   ru   rv   r~   r   r   r   r   r&   r&   r&   r'   rF      s,     !"%""!"" !!#FC-rF   c                   @   s2   e Zd ZejZdd Zdd Zdd Zdd Z	d	S )
TestChoiceFieldComparisonc                 C   s|   |  tjdtddtdd}| |j | |j | |	 d | |
 d | |
 t | |  d S )Naudiencepublicr   AudiencePublic)r   r   r   r   r   r   r   r   r   r   r    r!   r   r"   r#   r&   r&   r'   r(     r)   z,TestChoiceFieldComparison.test_hasnt_changedc                 C   r*   )Nr   r   r   privatezI<span class="deletion">Public</span><span class="addition">Private</span>
r   r   r   r   r   r    r!   r   r   r"   r#   r&   r&   r'   r.     r/   z*TestChoiceFieldComparison.test_has_changedc                 C   r;   )Nr   r   r   z%<span class="addition">Private</span>r   r#   r&   r&   r'   r<        
zETestChoiceFieldComparison.test_from_none_to_value_only_shows_additionc                 C   r>   )Nr   r   r   z$<span class="deletion">Public</span>r   r#   r&   r&   r'   r?     r   zETestChoiceFieldComparison.test_from_value_to_none_only_shows_deletionN)
r4   r5   r6   r   ChoiceFieldComparisonr   r(   r.   r<   r?   r&   r&   r&   r'   r     s    r   c                   @   s"   e Zd ZejZdd Zdd ZdS )TestTagsFieldComparisonc                 C   s   t  }|jd |jd t  }|jd |jd | t jd||}| |j | |j	 | 
| d | 
| d | | t | |  d S )NwagtailbirdtagsTagszwagtail, bird)r   r   addr   r   r   r   r   r   r   r   r   r    r!   r   r"   r$   abr%   r&   r&   r'   r(     s   z*TestTagsFieldComparison.test_hasnt_changedc                 C   s   t  }|jd |jd t  }|jd |jd | t jd||}| | d | | t	 | 
|  d S )Nr   r   	motacillar   zTwagtail, <span class="deletion">bird</span>, <span class="addition">motacilla</span>)r   r   r   r   r   r   r   r    r!   r   r   r"   r   r&   r&   r'   r.     s   z(TestTagsFieldComparison.test_has_changedN)r4   r5   r6   r   TagsFieldComparisonr   r(   r.   r&   r&   r&   r'   r     s    r   c                   @   s0   e Zd ZdgZejZdd Zdd Zdd Z	dS )	TestM2MFieldComparisonz	test.jsonc                 C   s4   t jjdd| _t jjdd| _t jjdd| _d S )NMeetings)ry   PartiesHolidays)r
   r   r   meetings_categoryparties_categoryholidays_category)r$   r&   r&   r'   setUp  s   zTestM2MFieldComparison.setUpc                 C   s   t jjdd}t jjdd}| j| jg|_| j| jg|_| t jd||}| 	|j
 | |j | | d | |  | | d | | t d S )N/home/events/christmas/url_path/home/events/saint-patrick/
categories
CategorieszMeetings, Parties)r   r   getr   r   r   r   r   r   r   r   r   r   r   r   r"   r    r!   r   r$   christmas_eventsaint_patrick_eventr%   r&   r&   r'   r(     s"   
z)TestM2MFieldComparison.test_hasnt_changedc                 C   s   t jjdd}t jjdd}| j| jg|_| j| jg|_| t j	d||}| 
|  | | d | | t d S )Nr   r   r   r   zWMeetings, <span class="deletion">Parties</span>, <span class="addition">Holidays</span>)r   r   r   r   r   r   r   r   r   r   r   r"   r   r    r!   r   r   r&   r&   r'   r.     s&   
z'TestM2MFieldComparison.test_has_changedN)
r4   r5   r6   fixturesr   M2MFieldComparisonr   r   r(   r.   r&   r&   r&   r'   r     s    r   c                   @   s.   e Zd ZejZedd Zdd Zdd Z	dS )TestForeignObjectComparisonc                 C   s2   t  }|jjdt d| _|jjdt d| _d S )Nr   r   r   )r   r   r   r   r   r   )clsr   r&   r&   r'   setUpTestData6  s   z)TestForeignObjectComparison.setUpTestDatac                 C   s   |  tjdt| jdt| jd}| |j | |j | 	|
 d | 	| d | | t | |  d S )N
feed_imager   z
Feed imager   )r   r   r   r   r   r   r   r   r   r   r   r    r!   r   r"   r#   r&   r&   r'   r(   B  s   


z.TestForeignObjectComparison.test_hasnt_changedc                 C   sX   |  tjdt| jdt| jd}| | d | | t	 | 
|  d S )Nr   r   zT<span class="deletion">Test image 1</span><span class="addition">Test image 2</span>)r   r   r   r   r   r   r   r    r!   r   r   r"   r#   r&   r&   r'   r.   P  s   


z,TestForeignObjectComparison.test_has_changedN)
r4   r5   r6   r   ForeignObjectComparisonr   classmethodr   r(   r.   r&   r&   r&   r'   r   3  s    
r   c                   @   s2   e Zd ZdZejZedd Zdd Z	dd Z
dS )	'TestForeignObjectComparisonWithCustomPKzNForeignObjectComparison works with models declaring a custom primary key fieldc                 C   sD   t jjddd}t jjddd}tjj|d| _tjj|d| _d S )Nad1Advert 1)	advert_idrI   ad2zAdvert 2)advertwithcustomprimarykey)r	   r   r   r   
test_obj_1
test_obj_2)r   r   r   r&   r&   r'   r   d  s   z5TestForeignObjectComparisonWithCustomPK.setUpTestDatac                 C   st   |  tjd| j| j}| |j | |j | 	|
 d | 	| d | | t | |  d S )Nr   Advertwithcustomprimarykeyr   )r   r   r   r   r   r   r   r   r   r   r   r    r!   r   r"   r#   r&   r&   r'   r(   s  s   z:TestForeignObjectComparisonWithCustomPK.test_hasnt_changedc                 C   sL   |  tjd| j| j}| | d | | t	 | 
|  d S )Nr   zL<span class="deletion">Advert 1</span><span class="addition">Advert 2</span>)r   r   r   r   r   r   r   r    r!   r   r   r"   r#   r&   r&   r'   r.     s   z8TestForeignObjectComparisonWithCustomPK.test_has_changedN)r4   r5   r6   __doc__r   r   r   r   r   r(   r.   r&   r&   r&   r'   r   _  s    
r   c                   @   @   e Zd ZejZejZdd Zdd Z	dd Z
dd Zd	d
 ZdS )TestChildRelationComparisonc           
   	   C   s  t ddd}|jtddd t ddd}|jtddd | t jdt| jtjdt| jtjd	g||}| 	|j
 | |j | | d
 | 	|  t|j }t|j }|||\}}}}	| |ddi | |ddi | |g  | |	g  d S )N
Event pageeventr   slugFather	Christmas
first_name	last_namespeakerr   r   Speakerr   r   speakersr   r   r   r   r   r   field_comparison_classr   r   r   r   r   r   r"   listval_aallval_bget_mapping
r$   
event_pagemodified_event_pager%   objs_aobjs_bmap_forwardsmap_backwardsaddeddeletedr&   r&   r'   r(     sR   



z.TestChildRelationComparison.test_hasnt_changedc           
   	   C   s:  t ddd}|jtdddd t ddd}|jtdd	dd |jtdd
dd | t jdt| jtjdt| jtjdg||}| 	|j
 | |j | | d | |  t|j }t|j }|||\}}}}	| |ddi | |ddi | |dg | |	g  d S )Nr   r   r   r   r   r   r   r   
sort_orderSantaClausTed   r   r   r   r   r   r   r&   r&   r'   r.     sd   



z,TestChildRelationComparison.test_has_changedc           
   	   C   s>  t ddd}|jtddddd t ddd}|jtdd	d
dd |jtdddd | t jdt| jtjdt| jtjdg||}| 	|j
 | |j | | d | |  t|j }t|j }|||\}}}}	| |ddi | |ddi | |dg | |	g  d S )Nr   r   r   r  r   r   r   )r   r   r   r  r  r	  r
  r  r   r   r   r   r   r   r&   r&   r'   test_has_changed_with_same_id	  sh   	



z9TestChildRelationComparison.test_has_changed_with_same_idc           
   	   C   s  t ddd}|jtdddd t ddd}|jtdddd | t jd	t| jtjd
t| jtjdg||}| 	|j
 | |j | | d | |  t|j }t|j }|||\}}}}	| |i  | |i  | |dg | |	dg d S )Nr   r   r   r  r   r   )r   r   r      r   r   r   r   r   r   r   r&   r&   r'   $test_hasnt_changed_with_different_idH  sV   



z@TestChildRelationComparison.test_hasnt_changed_with_different_idc                 C   s`   t ddd}|jtdd | jt jdt| jtjdg||dd	}| 	|
 d d S )
Nr   r   r   r   )r   r   r   Speakers)label)r   r   r   r   r   r   r   r   r   r   r   )r$   r   r%   r&   r&   r'   test_panel_label_as_field_label}  s$   

z;TestChildRelationComparison.test_panel_label_as_field_labelN)r4   r5   r6   r   r7   r   ChildRelationComparisonr   r(   r.   r  r  r  r&   r&   r&   r'   r     s    4=?5r   c                   @   r   )TestChildObjectComparisonc              	   C   s   t ddd}t ddd}| t t| jt jdt| jt jdg||}| |  | |  | |	  | 
| d | 
| d d S Nr   r   r   r   r   r   r   r   r   r   r   r   r   is_additionis_deletionr"   r   get_position_changeget_num_differencesr$   obj_aobj_br%   r&   r&   r'   test_same_object  6   


z*TestChildObjectComparison.test_same_objectc              	   C   s   t ddd}t ddd}| t t| jt jdt| jt jdg||}| |  | |  | 	|
  | | d | | d	 d S )
Nr   r   r   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_different_object  r  z/TestChildObjectComparison.test_different_objectc              	   C   s   t dddd}t dddd}| t t| jt jdt| jt jdg||}| |  | |  | |	  | 
| d | 
| d	 d S )
Nr   r   r  r     r   r      r   r  r  r&   r&   r'   test_moved_object  s:   


z+TestChildObjectComparison.test_moved_objectc              	   C   s   t ddd}| t t| jt jdt| jt jdgd |}| |  | |	  | |
  | | d | | d d S r  )r   r   r   r   r   r   r   r  r   r  r"   assertIsNoner  r   r  r$   objr%   r&   r&   r'   test_addition  s.   


z'TestChildObjectComparison.test_additionc              	   C   s   t ddd}| t t| jt jdt| jt jdg|d }| |  | |	  | |
  | |  | | d d S r  )r   r   r   r   r   r   r   r  r   r  r"   r#  r  r   r  r$  r&   r&   r'   test_deletion  s.   


z'TestChildObjectComparison.test_deletionN)r4   r5   r6   r   r7   r   ChildObjectComparisonr   r  r  r"  r&  r'  r&   r&   r&   r'   r    s    !!#r  c                   @   s,   e Zd ZdZejZejZdd Z	dd Z
dS )"TestChildRelationComparisonUsingPKzITest related objects can be compred if they do not use id for primary keyc           
      C   s   t ddd}|jtddd t ddd}|jtddd |jtdd	 | t jd
t| jtjdg||}| 	|j
 | |j | | d | |  t|j }t|j }|||\}}}}	| |ddi | |ddi | |dg | |	g  d S )NzSemi Finalszsemi-finals-2018r   r     	custom_id
head_count      )r-  head_countsr-  Head countsr   r   r0  r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r   r   r   r   r   r   r&   r&   r'   r  >  sT   

z@TestChildRelationComparisonUsingPK.test_has_changed_with_same_idc           
      C   s  t ddd}|jtddd t ddd}|jtddd | t jdt| jtjd	g||}| 	|j
 | |j | | d
 | |  t|j }t|j }|||\}}}}	| |i  | |i  | |dg | |	dg d S )NFinalszfinals-event-abcr   r     r+  r  r0  r-  r1  r   r2  r   r&   r&   r'   r  s  s>   



zGTestChildRelationComparisonUsingPK.test_hasnt_changed_with_different_idN)r4   r5   r6   r   r   r7   r   r  r   r  r  r&   r&   r&   r'   r)  8  s    5r)  N)$	functoolsr   django.testr   django.utils.safestringr   wagtail.adminr   wagtail.blocksr   wagtail.imagesr   wagtail.images.tests.utilsr   wagtail.test.testapp.modelsr	   r
   r   r   r   r   r   r   r   r   r8   rA   rF   r   r   r   r   r   r   r  r)  r&   r&   r&   r'   <module>   s8    ,/.3     z6(9,5   #