
    Mh                     h    d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	 d dl
mZ  G d d          ZdS )    )	lru_cacheN)RegistryResource
exceptions)DRAFT202012)to_cached_resourcec                   &    e Zd Zd Zd Zd Zd ZdS )TestToCachedResourcec                 B   ddi}t          j        |          gt                      fd            }t          |          }t	          j        |          }|                    d          }|j        |k    sJ |                    d          }|j        |j        u sJ d S )N$schema,https://json-schema.org/draft/2020-12/schemac                 ,                                     S Npopuristacks    `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/referencing/tests/test_retrieval.pyretrievezITestToCachedResource.test_it_caches_retrieved_resources.<locals>.retrieve       99;;    r   urn:example:schemajsondumpsr   r   r   from_contentsget_or_retrievevalueselfcontentsr   registryexpectedgotagainr   s          @r   "test_it_caches_retrieved_resourcesz7TestToCachedResource.test_it_caches_retrieved_resources   s    MNH%%&				 	 	 	 
		 X...)(33&&';<<yH$$$$ (()=>>{ci''''''r   c                 Z   ddi}t          j        |          d d d         gt          d           fd            }t          |          }t	          j        |          }|                    d          }|j        |k    sJ |                    d          }|j        |j        u sJ d S )	Nr   r   c                 <    t          j        | d d d                   S )Nr*   )r   loads)ss    r   <lambda>z9TestToCachedResource.test_custom_loader.<locals>.<lambda>#   s    DJq2w,?,? r   )r,   c                 ,                                     S r   r   r   s    r   r   z9TestToCachedResource.test_custom_loader.<locals>.retrieve#   r   r   r   r   r   r!   s          @r   test_custom_loaderz'TestToCachedResource.test_custom_loader   s    MNH%%ddd+,	"?"?	@	@	@	 	 	 	 
A	@	 X...)(33&&';<<yH$$$$ (()=>>{ci''''''r   c                 V   i }t          j        |          gt          t          j                  fd            }t          |          }t          j        |          }|                    d          }|j        |k    sJ |                    d          }|j        |j        u sJ d S )N)r   c                 ,                                     S r   r   r   s    r   r   z@TestToCachedResource.test_custom_from_contents.<locals>.retrieve6   r   r   r   r   )r   r   r   r   create_resourcer   r   r    r!   s          @r   test_custom_from_contentsz.TestToCachedResource.test_custom_from_contents2   s    H%%&	+*E	F	F	F	 	 	 	 
G	F	 X....x88&&';<<yH$$$$ (()=>>{ci''''''r   c                 P   ddi}t          |d          t          |d          t          |d          dd                                 D             }t          t          d	          
          fd            }t	          |          }|                    d          }|j        |d         k    sJ |                    d          j        |j        u sJ |                    d          j        |j        u sJ |                    d          }|j        |d         k    sJ |                    d          j        |j        u sJ |                    d          j        |j        u sJ |                    d          }|j        |d         k    sJ |                    d          j        |j        u sJ |                    d          j        |j        u sJ t          j        t          j
                  5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr   r      )foo      )urn:example:1urn:example:2urn:example:3c                 >    i | ]\  }}|t          j        |          S  )r   r   ).0r   r#   s      r   
<dictcomp>z:TestToCachedResource.test_custom_cache.<locals>.<dictcomp>M   s9     
 
 
X '11
 
 
r   )maxsize)cachec                 R    t          j                            |                     S r   )r   r   r   )r   mappings    r   r   z8TestToCachedResource.test_custom_cache.<locals>.retrieveR   s    :gkk#..///r   r   r:   r;   r<   )dictitemsr   r   r   r   r    pytestraisesr   Unretrievable)r"   schema	resourcesr   r$   r&   rD   s         @r   test_custom_cachez&TestToCachedResource.test_custom_cacheE   s   KL!&a000!&a000!&a000
 

 
!(
 
 
	
 
)A"6"6"6	7	7	7	0 	0 	0 	0 
8	7	0 X...&&77yIo66666''88>#)KKKK''88>#)KKKK&&77yIo66666''88>#)KKKK''88>#)KKKK &&77yIo66666''88>#)KKKK''88>#)KKKK ]:344 	6 	6$$_555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6s   8HH"HN)__name__
__module____qualname__r(   r0   r4   rL   r>   r   r   r
   r
      sP        ( ( (&( ( (&( ( (&%6 %6 %6 %6 %6r   r
   )	functoolsr   r   rG   referencingr   r   r   referencing.jsonschemar   referencing.retrievalr   r
   r>   r   r   <module>rT      s            6 6 6 6 6 6 6 6 6 6 . . . . . . 4 4 4 4 4 4_6 _6 _6 _6 _6 _6 _6 _6 _6 _6r   