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 )a  
Check that all changes to Treebeard models have had migrations created in our test app. If there
are outstanding model changes that need migrations, fail the tests.

This module is taken from https://github.com/wagtail/wagtail/blob/master/wagtail/core/tests/test_migrations.py.
    )apps)MigrationAutodetector)MigrationLoader)MigrationQuestioner)ProjectState)TestCasec                   @   s   e Zd Zdd ZdS )TestForMigrationsc                    s   t dd t D   D ]}t|dd  qtd dd}t fdd|  D }|rDd	d	d | D }| 
d
|  t| ttt dd}|j|j pZd  p]d d}|rwd	dd | D }| 
d|  d S d S )Nc                 s   s"    | ]}|j d r|jV  qdS )ztests.N)name
startswithlabel).0app r   _/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/treebeard/tests/test_migrations.py	<genexpr>   s     z5TestForMigrations.test__migrations.<locals>.<genexpr>.T)ignore_no_migrationsc                 3   s$    | ]\}}| v r||fV  qd S )Nr   )r   	app_labelconflict
app_labelsr   r   r      s    z; c                 s   s&    | ]\}}d d ||f V  qdS )z%s in %sz, N)join)r   r   namesr   r   r   r      s   $ 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    {0}N)formatdescribe)r   	operationr   r   r   r   1   s    z?TestForMigrations.test__migrations.<locals>.<genexpr>.<genexpr>)	migrationchangesN)r    r   
operations)r   _
migrationsr#   r   r   r   r   .   s    
z-Model changes with no migrations detected:
%s)setr   get_app_configsget_app_configsplitr   dictdetect_conflictsitemsr   failr   project_stater   	from_appsr   r$   r   )selfr   loader	conflictsname_strautodetectorr$   r'   r   r   r   test__migrations   s4   


z"TestForMigrations.test__migrationsN)__name__
__module____qualname__r7   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    