
    hs                         d dl Z 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mZmZmZmZmZmZmZmZmZ ddlmZ d	 Z G d
 de      Zy)    Nwraps)models)Manager)TranslatableModelTranslatedFields   )
	CharModelDoubleModelLevel1Level2ManualModelManualModelTranslations	ProxyBase
ProxyModelRegularModelSimpleModel)AppTestCasec                 .     t                fd       }|S )zd
    Decorator for unit tests that corrupt the global app registry, and therefore need a reset.
    c                  n    ddl m} 	  | i | |j                          y # |j                          w xY w)Nr   )apps)django.appsr   clear_cache)argskwargsr   funcs      T/home/dcms/DCMS/lib/python3.12/site-packages/parler/tests/test_model_construction.py_clearing_decz)clear_app_registry.<locals>._clearing_dec   s3    $	$!&! Ds   " 4r   )r   r   s   ` r   clear_app_registryr      s#    
 4[      c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	ModelConstructionTestsz!
    Test model construction
    c                    | j                  t               j                  t               | j	                  t               j                  j
                  t               | j	                  t        j                  j                  t               y)z2
        Test the metaclass of the model.
        N)	assertIsInstancer   translationsr   assertIsmodelr   _parler_meta
root_modelselfs    r   test_manual_modelz(ModelConstructionTests.test_manual_model/   sT    
 	km88'Bkm00668OPk..99;RSr    c                     | j                  t               j                  j                  t        j                  j
                         y)z/
        Test the simple model syntax.
        N)r&   r   r%   r'   r(   r)   r*   s    r   test_simple_modelz(ModelConstructionTests.test_simple_model8   s,     	km00668P8P8[8[\r    c                    | j                  t        j                  j                  j                  d       | j                  t        j                  j                  j
                  j                  d       | j                  t        t        j                        d       | j                  t        t        j                        d       | j                  t        j                  d   j                  d       | j                  t        j                  d   j                  d       | j                  t        j                  d   j
                  j                  d       | j                  t        j                  j                  j                  d       | j                  t        j                  j                  d       | j                  t        j                  j                  t        j                  j                         y)	z2
        Test the inherited model syntax.
        l1_translationsLevel1Translationr	      r   l2_translationsLevel2TranslationN)assertEqualr   r(   rootrel_namer'   __name__lenr   r)   root_rel_namer*   s    r   test_inherited_modelz+ModelConstructionTests.test_inherited_model>   s^   
 	,,11::<MN,,1177@@BUVV00115 	V00115,,Q/88:KL,,Q/88:KL,,Q/55>>@ST 	,,77@@BUV,,::<MN,,1163F3F3K3KLr    c                    | j                  t        j                  j                  j                  d       | j                  t        t        j                        d       | j                  t        t        j                        d       | j                  t        j                  d   j                  d       | j                  t        j                  d   j                  d       | j                  t        j                  d   j                  j                  d       | j                  t        j                  d   j                  j                  d       | j                  t        j                  j                  j                  d       | j                  t        j                  j                  d       | j                  t        j                  j                  t        j                  j                         y)	zD
        Test whether proxy models can get new translations
        base_translationsr	   r2   r   proxy_translationsProxyBaseTranslationProxyModelTranslationN)r5   r   r(   r6   r7   r9   r   r'   r8   r)   r:   r*   s    r   test_proxy_modelz'ModelConstructionTests.test_proxy_modelR   s]   
 	//44==?RSY334a8 	Z445q9003<<>QR003<<>RS00399BBDZ[00399BBD[\ 	00;;DDF\]00>>@ST0055y7M7M7R7RSr    c                 \   | j                  t        j                  j                         | j	                  t        t        j                        d       | j	                  t        j                  d   j                  d       | j	                  t        j                  d   j                  d       y)zB
        Test how assigning two translation tables works.
        r2   r   r=   r	   more_translationsN)assertIsNoner   r(   baser5   r9   r7   r*   s    r   test_double_translation_tablez4ModelConstructionTests.test_double_translation_tableg   s     	$$))	
 	[556:11!4==?RS11!4==?RSr    c                     | j                  t        j                  j                  d      t               | j                  t        j                  j                  dd      t               y)zP
        Test that TranslatableModels works with different types of pks
        Test)tr_titletest)pkrI   N)r$   r   objectscreater
   r*   s    r   test_model_with_different_pksz4ModelConstructionTests.test_model_with_different_pksr   sO     	k1188&8I;Wi//66&66RT]^r    N)
r8   
__module____qualname____doc__r,   r.   r;   rA   rF   rN    r    r   r"   r"   *   s+    T]M(T*	T_r    r"   )unittest	functoolsr   	django.dbr   django.db.modelsr   parler.modelsr   r   testapp.modelsr
   r   r   r   r   r   r   r   r   r   utilsr   r   r"   rR   r    r   <module>rZ      s=       $ =   $M_[ M_r    