o
    h                     @   s   d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
 d dlmZmZ d dlmZ G dd	 d	e
eeZG d
d de
eeZdS )    )TestCase)reverse)timezone)PageSite)	Benchmark)SingleEventPage
StreamPage)WagtailTestUtilsc                   @       e Zd ZdZdd Zdd ZdS )!BenchPageExplorerWith50LargePagesz
    Creates 50 pages with large body content and benches the explorer.
    This will be slow if the body content is being loaded from the database.
    c                 C   s   t jjdd| _tjjd| jd ddddd	  gd
  d }tdD ]}| jjt	d|d  t
|d |dd q%|   d S )N   idTis_default_site	root_page[,z{"type": "text", "value": "%s"}fooi  d   ]2   zPage )titleslugbodyinstance)r   objectsgetr   r   createjoinrange	add_childr	   strlogin)selfr   i r(   [/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/admin/tests/benches.pysetUp   s"   
z'BenchPageExplorerWith50LargePages.setUpc                 C   sD   | j td| jjfd}| |jd | |d | |d d S )Nwagtailadmin_exploreargs   zPage 1zPage 49clientr   r   r   r   assertEqualstatus_codeassertContainsr&   responser(   r(   r)   bench*   s   z'BenchPageExplorerWith50LargePages.benchN__name__
__module____qualname____doc__r*   r6   r(   r(   r(   r)   r      s    r   c                   @   r   )#BenchPageExplorerWithCustomURLPagesz
    Creates 50 pages of a class with a customised the .url property.
    This will check how long it takes to generate URLs for all of these
    pages.
    c              
   C   sp   t jjdd| _tjjd| jd tdD ]}| jjtd|d  t	|d t
 ddd	d
d q|   d S )Nr   r   Tr   r   zEvent public	reykjavikcost)r   r   	date_fromaudiencelocationr?   r   )r   r   r   r   r   r    r"   r#   r   r$   r   nowr%   )r&   r'   r(   r(   r)   r*   >   s   
z)BenchPageExplorerWithCustomURLPages.setUpc                 C   sP   | j td| jjfd}| |jd | |d | |d | |d d S )Nr+   r,   r.   zEvent 1zEvent 49z%a href="http:///49/pointless-suffix/"r/   r4   r(   r(   r)   r6   S   s   z)BenchPageExplorerWithCustomURLPages.benchNr7   r(   r(   r(   r)   r<   7   s    r<   N)django.testr   django.urlsr   django.utilsr   wagtail.modelsr   r   wagtail.test.benchmarkr   wagtail.test.testapp.modelsr   r	   wagtail.test.utilsr
   r   r<   r(   r(   r(   r)   <module>   s    ,