o
    h                     @   s`   d 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Zd
S )z
Check that all changes to Wagtail models have had migrations created. If there
are outstanding model changes that need migrations, fail the tests.
    )apps)MigrationAutodetector)MigrationLoader)MigrationQuestioner)ProjectState)TestCasec                   @   s   e Zd Zdd ZdS )TestForMigrationsc                    s   dd t  D   D ]}t |dd  qtd dd} fdd|  D }|r@dd	d
 | D }| d|  t	|
 tt t dd}|j|j pVd  pYd d}|rsddd
 | D }| d|  d S d S )Nc                 S   s&   h | ]}|j d d dkr|jqS ).r   wagtail)namesplitlabel).0app r   ]/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/tests/test_migrations.py	<setcomp>   s
    z5TestForMigrations.test__migrations.<locals>.<setcomp>r	   T)ignore_no_migrationsc                    s    h | ]\}}| v r||fqS r   r   )r   	app_labelconflict
app_labelsr   r   r      s
    z; c                 s   s&    | ]\}}d  d||V  qdS )z{} in {}z, N)formatjoin)r   r   namesr   r   r   	<genexpr>    s
    
z5TestForMigrations.test__migrations.<locals>.<genexpr>z%Conflicting migrations detected (%s).)specified_appsdry_run)graphtrim_to_appsconvert_apps
c                 s   s>    | ]\}}|D ]}d j |ddd |jD dV  qqdS )z  {migration}
{changes}r"   c                 s   s    | ]
}d |   V  qdS )z    N)describe)r   	operationr   r   r   r   6   s
    
z?TestForMigrations.test__migrations.<locals>.<genexpr>.<genexpr>)	migrationchangesN)r   r   
operations)r   _
migrationsr%   r   r   r   r   3   s    	
z-Model changes with no migrations detected:
%s)r   get_app_configsget_app_configr   r   detect_conflictsitemsr   failr   project_stater   	from_appsr   r&   r   )selfr   loader	conflictsname_strautodetectorr&   r)   r   r   r   test__migrations   s<   




z"TestForMigrations.test__migrationsN)__name__
__module____qualname__r6   r   r   r   r   r      s    r   N)__doc__django.appsr   !django.db.migrations.autodetectorr   django.db.migrations.loaderr   django.db.migrations.questionerr   django.db.migrations.stater   django.testr   r   r   r   r   r   <module>   s    