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
 d dlmZ d dlmZ d dlmZ G dd	„ d	eeƒZG d
d„ deƒZG dd„ deƒZdS )é    )ÚTestCase)Úreverse_lazy)Úget_document_model)ÚDocumentLinkHandler)ÚRichTextField)ÚFeatureRegistry)ÚWagtailTestUtilsc                   @   ó2   e Zd ZdgZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú!TestEditorHtmlDocumentLinkHandlerú	test.jsonc                 C   s.   |   d¡}|j}t |¡}|  |ddi¡ d S )Nz<a data-id="test-id">foo</a>Úidztest-id)Úget_soupÚaÚEditorHtmlDocumentLinkHandlerÚget_db_attributesÚassertEqual)ÚselfÚsoupÚtagÚresult© r   úf/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/documents/tests/test_rich_text.pyÚtest_get_db_attributes   s   

z8TestEditorHtmlDocumentLinkHandler.test_get_db_attributesc                 C   ó   t  ddi¡}|  |d¡ d S )Nr   é   zE<a data-linktype="document" data-id="1" href="/documents/1/test.pdf">©r   Úexpand_db_attributesr   ©r   r   r   r   r   Ú$test_expand_db_attributes_for_editor   s
   þzFTestEditorHtmlDocumentLinkHandler.test_expand_db_attributes_for_editorc                 C   r   )Nr   r   z(<a data-linktype="document" data-id="0">r   r   r   r   r   ÚItest_expand_db_attributes_for_editor_preserves_id_of_nonexistent_document    ó   zkTestEditorHtmlDocumentLinkHandler.test_expand_db_attributes_for_editor_preserves_id_of_nonexistent_documentc                 C   ó   t  i ¡}|  |d¡ d S )Nz<a data-linktype="document">r   r   r   r   r   Ú4test_expand_db_attributes_for_editor_with_missing_id$   ó   
zVTestEditorHtmlDocumentLinkHandler.test_expand_db_attributes_for_editor_with_missing_idN)Ú__name__Ú
__module__Ú__qualname__Úfixturesr   r   r   r"   r   r   r   r   r
      s    r
   c                   @   r	   )ÚTestFrontendDocumentLinkHandlerr   c                 C   r   )Nr   r   z <a href="/documents/1/test.pdf">©ÚFrontendDocumentLinkHandlerr   r   r   r   r   r   Ú&test_expand_db_attributes_for_frontend,   r    zFTestFrontendDocumentLinkHandler.test_expand_db_attributes_for_frontendc                 C   r   )Nr   r   ú<a>r)   r   r   r   r   Ú1test_expand_db_attributes_document_does_not_exist0   r    zQTestFrontendDocumentLinkHandler.test_expand_db_attributes_document_does_not_existc                 C   r!   )Nr,   r)   r   r   r   r   Ú)test_expand_db_attributes_with_missing_id4   r#   zITestFrontendDocumentLinkHandler.test_expand_db_attributes_with_missing_idc                 C   s(   |   ttƒ  d¡ƒtƒ dddfg¡ d S )Nz4<a linktype="document" id="1">Link to a document</a>Ú1Ú )r   Úlistr   Úextract_referencesr   )r   r   r   r   Útest_extract_references8   s   ÿÿúz7TestFrontendDocumentLinkHandler.test_extract_referencesN)r$   r%   r&   r'   r+   r-   r.   r3   r   r   r   r   r(   )   s    r(   c                   @   s   e Zd Zdd„ ZdS )ÚTestEntityFeatureChooserUrlsc                 C   sB   t ƒ }| dd¡}|  |j d¡¡ |  |jd d tdƒ¡ d S )NÚdraftailzdocument-linkÚchooserUrlsÚdocumentChooserzwagtaildocs_chooser:choose)r   Úget_editor_pluginÚassertIsNotNoneÚdataÚgetr   r   )r   ÚfeaturesÚdocumentr   r   r   Útest_chooser_urls_existD   s   þz4TestEntityFeatureChooserUrls.test_chooser_urls_existN)r$   r%   r&   r>   r   r   r   r   r4   C   s    r4   N)Údjango.testr   Údjango.urlsr   Úwagtail.documentsr   Úwagtail.documents.rich_textr   r*   Ú'wagtail.documents.rich_text.editor_htmlr   Úwagtail.fieldsr   Ú"wagtail.rich_text.feature_registryr   Úwagtail.test.utilsr   r
   r(   r4   r   r   r   r   Ú<module>   s    