a
    
dK-                  
   @   sl  d dl Z d dlmZmZmZ d dlZe jddejj	fdejj
fdejjfdejjfdejjfd	ejjfgd
d Zdd Ze jddejj	fdejj
fdejjfdejjfdejjfdejjfgdd Ze jdejj	ejj
ejjejjge jdddgdd Ze jdejj	ejj
ejjejjge jdddgdd Ze jdejj	ejj
ejjejjge jdddgdd Ze jddejj	fdejj
fdejjfdejjfdejjfd	ejjfgdd Ze jddejjfd ejjfd!ejjfd"ejjfgd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 ZdS )7    N)RegistryResourceSpecificationzuri, expectedz,https://json-schema.org/draft/2020-12/schemaz,https://json-schema.org/draft/2019-09/schemaz'http://json-schema.org/draft-07/schema#z'http://json-schema.org/draft-06/schema#z'http://json-schema.org/draft-04/schema#z'http://json-schema.org/draft-03/schema#c                 C   s*   d| i}t |}|t ||dks&J dS )zE
    The $schema keyword in JSON Schema is a dialect identifier.
    $schema)contentsspecificationN)r   from_contents)uriexpectedr   resource r   j/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/referencing/tests/test_jsonschema.py7test_schemas_with_explicit_schema_keywords_are_detected   s    !
r   c                  C   sT   d} t tjj}td| i W d    n1 s60    Y  |jj| ksPJ d S )N1http://example.com/unknown-json-schema-dialect-idr   )	pytestraisesreferencing
jsonschemaUnknownDialectr   r   valuer	   
dialect_idexcinfor   r   r   test_unknown_dialect-   s    ,r   zid, specification$ididc                 C   s   d}| | |i|ksJ d S )Nzhttp://example.com/some-schemaZid_of)r   r   r	   r   r   r   test_id_of_mapping4   s    r   r   r   TFc                 C   s   |  |d u sJ d S Nr   r   r   r   r   r   test_id_of_boolD   s    r    c                 C   s   t | |g ksJ d S r   )listZ
anchors_inr   r   r   r   test_anchors_in_boolR   s    r"   c                 C   s   t | |g ksJ d S r   )r!   Zsubresources_ofr   r   r   r   test_subresources_of_bool`   s    r#   c                 C   s   t j| |ksJ d S r   r   r   specification_withr	   r
   r   r   r   test_specification_withn   s    r'   z&http://json-schema.org/draft-07/schemaz&http://json-schema.org/draft-06/schemaz&http://json-schema.org/draft-04/schemaz&http://json-schema.org/draft-03/schemac                 C   s   t j| |ksJ d S r   r$   r&   r   r   r   )test_specification_with_no_empty_fragment   s    r(   c                  C   sR   d} t tjj}tj|  W d    n1 s40    Y  |jj| ksNJ d S )Nr   )r   r   r   r   r   r%   r   r	   r   r   r   r   'test_specification_with_unknown_dialect   s    *r)   c                  C   s(   d} t jj| tjd}|tju s$J d S )Nr   )default)r   r   r%   r   ZOPAQUE)r   r   r   r   r   test_specification_with_default   s    r+   c                  C   sB   t jjddi} t d|  }|d}|j| jks>J d S )N$dynamicAnchorfoohttp://example.comzhttp://example.com#foo)	r   r   DRAFT202012create_resourcer   with_resourceresolverlookupr   )oner2   resolvedr   r   r   test_lookup_trivial_dynamic_ref   s    
r6   c               
   C   s   t jjd} t jjddddddddiddid}t d|fd| fd	|fg }|d}|jd
}|jdj}|d}|j|jksJ d S )NTr.   	fooAnchorr-   r,   barZbazr   r,   $defshttp://example.com/foo/http://example.com/foo/barfoo/r9   
#fooAnchor	r   r   r/   r0   r   with_resourcesr2   r3   r   TRUErootr2   firstsecondfourthr   r   r   (test_multiple_lookup_trivial_dynamic_ref   s6    

rH   c               
   C   s   t jjddi} t jjddddddddiddid}t d|fd	| fd
|fg }|d}|jd}|jdj}|d}|j|jksJ d S )N$anchorr7   r.   r-   Tr,   r8   r:   r<   r=   r>   r9   r?   r@   )r4   twor2   rE   rF   rG   r   r   r   2test_multiple_lookup_dynamic_ref_to_nondynamic_ref   s:    

rK   c                  C   sR   t jjddi} t d|  }|d}t jj|jd}|j	| j	ksNJ d S )N$recursiveAnchorTr.   r2   )
r   r   DRAFT201909r0   r   r1   r2   r3   lookup_recursive_refr   )r4   r2   rE   r5   r   r   r   !test_lookup_trivial_recursive_ref  s    
rP   c                  C   sD   t jjd} td| i}t jj|jddd}|j| jks@J d S )NTr.   )Zbase_urirM   )r   r   rN   r0   r   rO   r2   r   )rC   registryr5   r   r   r   !test_lookup_recursive_ref_to_bool  s    
rR   c                  C   s   t jjd} t jjdddddddddddid}t d|fd| fd	|fg }|d}|jd
}|jdj}t jj|d}|j	|j	ksJ d S )NTr.   r-   r7   rL   rI   r8   r   rL   r;   r<   r=   r>   r9   rM   
r   r   rN   r0   r   rA   r2   r3   rO   r   rB   r   r   r   *test_multiple_lookup_recursive_ref_to_bool(  s8    
rV   c                  C   s   t jjddi} t jjdddddddddddid}t jjdd	i}t d|fd
|fd| fg }|d}|jd}|jdj}t jj|d}|j	|j	ksJ d S )NrL   Tr.   r-   r7   rS   r8   rT   Fr<   r=   r>   r9   rM   rU   )r4   rJ   Zthreer2   rE   rF   rG   r   r   r   8test_multiple_lookup_recursive_ref_with_nonrecursive_refP  sB    
rW   ) r   r   r   r   r   Zreferencing.jsonschemamarkZparametrizer   r/   rN   ZDRAFT7ZDRAFT6ZDRAFT4ZDRAFT3r   r   r   r    r"   r#   r'   r(   r)   r+   r6   rH   rK   rP   rR   rV   rW   r   r   r   r   <module>   s   
	






			

	')	(