o
    h                     @   sr   d dl 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 edgd	G d
d deeZdS )    N)ContentFile)TestCase)override_settings)reverse)models)WagtailTestUtilselasticsearch) _WAGTAILSEARCH_FORCE_AUTO_UPDATEc                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestIssue613c                 C   s4   ddl m} ddlm} d|jvrtd|dS )Nr   )settings)get_search_backendr   zNo elasticsearch backend active)django.confr   wagtail.search.backendsr   WAGTAILSEARCH_BACKENDSunittestSkipTest)selfr   r    r   c/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/documents/tests/test_search.pyget_elasticsearch_backend   s
   

z&TestIssue613.get_elasticsearch_backendc                 C   s   |   | _|   d S )N)r   search_backendlogin)r   r   r   r   setUp   s   
zTestIssue613.setUpc                 K   sn   t d}d|_d|d}|| | jtd|}| |td tjj	j
|d d}| |  | S )	N   A boring example documenttest.txtTest documenttitlefilezwagtaildocs:addwagtaildocs:indexr   r   )r   nameupdateclientpostr   assertRedirectsr   Documentobjectsfilter
assertTrueexistsfirst)r   params	fake_file	post_dataresponsedocr   r   r   add_document   s   
zTestIssue613.add_documentc                 K   s   t d}d|_tjjjd|d}t d}d|_d|d}|| | jt	d|j
fd|}| |t	d tjjj|d	 d
}| |  | S )Nr   r   r   r   zTest document changed!zwagtaildocs:edit)argsr   r   r    )r   r!   r   r&   r'   creater"   r#   r$   r   idr%   r(   r)   r*   r+   )r   r,   r-   documentanother_fake_filer.   r/   r0   r   r   r   edit_document1   s    
zTestIssue613.edit_documentc                 C   f   | j   | j tj | jdd}| j   | j dtj}| t	|d | |d j
|j
 d S Nhello)tags   r   )r   reset_indexadd_typer   r&   r1   refresh_indexsearchassertEquallenr4   r   r5   resultsr   r   r   test_issue_613_on_addO      

z"TestIssue613.test_issue_613_on_addc                 C   r8   r9   )r   r=   r>   r   r&   r7   r?   r@   rA   rB   r4   rC   r   r   r   test_issue_613_on_edit_   rF   z#TestIssue613.test_issue_613_on_editN)	__name__
__module____qualname__r   r   r1   r7   rE   rG   r   r   r   r   r
      s    
r
   )r   django.core.files.baser   django.testr   django.test.utilsr   django.urlsr   wagtail.documentsr   wagtail.test.utilsr   r
   r   r   r   r   <module>   s    
