
    sg-              
          S SK r S SKJrJrJr  S SKr\ R                  R                  SS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S	\R                  R                  4/5      S
 5       rS r\ R                  R                  SS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4/5      S 5       r\ R                  R                  S\R                  R                  \R                  R                  \R                  R                  \R                  R                  /5      \ R                  R                  SSS/5      S 5       5       r\ R                  R                  S\R                  R                  \R                  R                  \R                  R                  \R                  R                  /5      \ R                  R                  SSS/5      S 5       5       r\ R                  R                  S\R                  R                  \R                  R                  \R                  R                  \R                  R                  /5      \ R                  R                  SSS/5      S 5       5       r\ R                  R                  SS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4S	\R                  R                  4/5      S 5       r\ R                  R                  SS\R                  R                  4S\R                  R                  4S\R                  R                  4S\R                  R                  4/5      S 5       rS rS rS rS  rS! rS" rS# rS$ rS% rS& r g)'    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                 V    SU 0n[         R                  " U5      nU[        X!S9:X  d   eg)z=
The $schema keyword in JSON Schema is a dialect identifier.
$schema)contentsspecificationN)r   from_contents)uriexpectedr   resources       C/usr/lib/python3/dist-packages/referencing/tests/test_jsonschema.py7test_schemas_with_explicit_schema_keywords_are_detectedr      s2    B 3H%%h/HxJJJJ    c                      Sn [         R                  " [        R                  R                  5       n[
        R                  " SU 05        S S S 5        WR                  R                  U :X  d   eg ! , (       d  f       N+= f)N1http://example.com/unknown-json-schema-dialect-idr   )	pytestraisesreferencing
jsonschemaUnknownDialectr   r
   valuer   
dialect_idexcinfos     r   test_unknown_dialectr   -   sZ    DJ	{--<<	=	:67 
>==
*** 
>	=s   A//
A=zid, specification$ididc                 8    SnUR                  X05      U:X  d   eg )Nzhttp://example.com/some-schemaid_of)r   r	   r   s      r   test_id_of_mappingr"   4   s$     +Cy)S000r   r	   r   TFc                 ,    U R                  U5      b   eg Nr    r	   r   s     r   test_id_of_boolr&   D   s     u%---r   c                 D    [        U R                  U5      5      / :X  d   eg r$   )list
anchors_inr%   s     r   test_anchors_in_boolr*   R   s"     ((/0B666r   c                 D    [        U R                  U5      5      / :X  d   eg r$   )r(   subresources_ofr%   s     r   test_subresources_of_boolr-   `   s"     --e45;;;r   c                 N    [         R                  R                  U 5      U:X  d   eg r$   r   r   specification_withr   r   s     r   test_specification_withr2   n   s#    < !!44S9XEEEr   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                 N    [         R                  R                  U 5      U:X  d   eg r$   r/   r1   s     r   )test_specification_with_no_empty_fragmentr4      s#    , !!44S9XEEEr   c                     Sn [         R                  " [        R                  R                  5       n[        R                  R                  U 5        S S S 5        WR                  R                  U :X  d   eg ! , (       d  f       N+= f)Nr   )r   r   r   r   r   r0   r   r   r   s     r   'test_specification_with_unknown_dialectr6      s[    DJ	{--<<	=11*= 
>==
*** 
>	=s    A66
Bc                      Sn [         R                  R                  U [        R                  S9nU[        R                  L d   eg )Nr   )default)r   r   r0   r   OPAQUE)r   r	   s     r   test_specification_with_defaultr:      sD    DJ**==$$ > M M00000r   c                     [         R                  R                  R                  SS05      n [	        5       R                  SU 5      R                  5       nUR                  S5      nUR                  U R                  :X  d   eg )N$dynamicAnchorfoohttp://example.comzhttp://example.com#foo)	r   r   DRAFT202012create_resourcer   with_resourceresolverlookupr   )onerB   resolveds      r   test_lookup_trivial_dynamic_refrF      sm    

 
 
,
,
<
<	5!C z''(<cBKKMH78H,,,r   c            
      "   [         R                  R                  R                  S5      n [         R                  R                  R                  SSSSSSSS0S.S.0S.5      n[	        5       R                  SU4SU 4S	U4/5      R                  5       nUR                  S5      nUR                  R                  S
5      nUR                  R                  S5      R                  nUR                  S5      nUR                  UR                  :X  d   eg )NTr>   	fooAnchorr=   r<   barbazr   r<   $defshttp://example.com/foo/http://example.com/foo/barfoo/rJ   
#fooAnchor	r   r   r?   r@   r   with_resourcesrB   rC   r   TRUErootrB   firstsecondfourths         r   (test_multiple_lookup_trivial_dynamic_refrZ      s	   !!--==dCD!!--==') &1#,k 		
D& 	
	%t,*D1-t4

 
  OO01E^^""6*F%%e,55H__\*F??dmm+++r   c            
      &   [         R                  R                  R                  SS05      n [         R                  R                  R                  SSSSSSSS0S.S.0S.5      n[	        5       R                  SU4S	U 4S
U4/5      R                  5       nUR                  S5      nUR                  R                  S5      nUR                  R                  S5      R                  nUR                  S5      nUR                  UR                  :X  d   eg )N$anchorrH   r>   r=   Tr<   rI   rL   rN   rO   rP   rJ   rQ   rR   )rD   tworB   rW   rX   rY   s         r   2test_multiple_lookup_dynamic_ref_to_nondynamic_refr^      s   

 
 
,
,
<
<	K C 
 
 
,
,
<
<') &1#,k 		
C& 	
	%s+*C0-s3

 
  OO01E^^""6*F%%e,55H__\*F??cll***r   c                  R   [         R                  R                  R                  SS05      n [	        5       R                  SU 5      R                  5       nUR                  S5      n[         R                  R                  UR                  S9nUR                  U R                  :X  d   eg )N$recursiveAnchorTr>   rB   )
r   r   DRAFT201909r@   r   rA   rB   rC   lookup_recursive_refr   )rD   rB   rW   rE   s       r   !test_lookup_trivial_recursive_refrd     s    

 
 
,
,
<
<	T"C z''(<cBKKMHOO01E%%:: ; H ,,,r   c                      [         R                  R                  R                  S5      n [	        SU 05      n[         R                  R                  UR                  SS9S9nUR                  U R                  :X  d   eg )NTr>   )base_urira   )r   r   rb   r@   r   rc   rB   r   )rU   registryrE   s      r   !test_lookup_recursive_ref_to_boolrh     su    !!--==dCD-t45H%%::"",@"A ; H ---r   c                  <   [         R                  R                  R                  S5      n [         R                  R                  R                  SSSSSSSSS.S.S.0S.5      n[	        5       R                  SU4SU 4S	U4/5      R                  5       nUR                  S5      nUR                  R                  S
5      nUR                  R                  S5      R                  n[         R                  R                  US9nUR                  UR                  :X  d   eg )NTr>   r=   rH   r`   r\   rI   r   r`   rM   rN   rO   rP   rJ   ra   
r   r   rb   r@   r   rS   rB   rC   rc   r   rT   s         r   *test_multiple_lookup_recursive_ref_to_boolrm   (  s   !!--==dCD!!--==' $ (,#04'2 
	
D( 	
	%t,*D1-t4

 
  OO01E^^""6*F%%e,55H##88(8KF??dmm+++r   c                     [         R                  R                  R                  SS05      n [         R                  R                  R                  SSSSSSSSS.S.S.0S.5      n[         R                  R                  R                  SS	05      n[	        5       R                  SU4S
U4SU 4/5      R                  5       nUR                  S5      nUR                  R                  S5      nUR                  R                  S5      R                  n[         R                  R                  US9nUR                  UR                  :X  d   eg )Nr`   Tr>   r=   rH   rj   rI   rk   FrN   rO   rP   rJ   ra   rl   )rD   r]   threerB   rW   rX   rY   s          r   8test_multiple_lookup_recursive_ref_with_nonrecursive_refrp   P  sE   

 
 
,
,
<
<	T"C 
 
 
,
,
<
<' $ (,#04'2 
	
C& ""..>>	U#E 	
	%u-*C0-s3

 
  OO01E^^""6*F%%e,55H##88(8KF??cll***r   c                  T    [         R                  R                  [        5       :X  d   eg r$   )r   r   EMPTY_REGISTRYr    r   r   test_empty_registryrt   }  s    !!00HJ>>>r   )!r   r   r   r   r   referencing.jsonschemamarkparametrizer   r?   rb   DRAFT7DRAFT6DRAFT4DRAFT3r   r   r"   r&   r*   r-   r2   r4   r6   r:   rF   rZ   r^   rd   rh   rm   rp   rt   rs   r   r   <module>r|      s    9 9   ;""..	

 ;""..	

 6""))	

 6""))	

 6""))	

 6""))	
+:K;:K+ 	&&223	&&223	&&--.	&&--.	{%%,,-	{%%,,-
1
1
 ****%%%%	 4-0. 1. ****%%%%	 4-07 17 ****%%%%	 4-0< 1<  ;""..	

 ;""..	

 6""))	

 6""))	

 6""))	

 6""))	
+:F;:F  5""))	

 5""))	

 5""))	

 5""))	
*F+*F+1-$,N&+R	-.%,P*+Z?r   