HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/referencing/tests/__pycache__/test_core.cpython-39.pyc
a

�,�hޓ�@s�ddlmZddlZddlmZmZmZmZmZddl	m
Z
eddd�dd�d	d�d
d�d�Zdd
�ZGdd�d�Z
Gdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zej�deeeeejg�dd��ZdS)�)�HashTrieMapN)�Anchor�Registry�Resource�
Specification�
exceptions)�DRAFT202012zid-and-childrencCs
|�d�S)N�ID��get��contents�r�L/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/referencing/tests/test_core.py�<lambda>	�rcCs|�dg�S)N�childrenr
rrrrr
rcs�fdd�|�di���D�S)Ncs$g|]\}}t|�j|d�d��qS)r��name�resource)r�create_resource)�.0r�each��
specificationrr�
<listcomp>s
�
�z<lambda>.<locals>.<listcomp>�anchors)r�items�rr
rrrrs
�cCs6t|�ds2tdd�|ddd�D��r2|�|�S|S)N�css|]}|dkVqdS)rNr�rrrrr�	<genexpr>rz<lambda>.<locals>.<genexpr>)�len�all�in_subresource��segments�resolverZsubresourcerrrrs

���r�id_of�subresources_of�
anchors_inZmaybe_in_subresourcecCstd��dS)zQ
    A retriever suitable for use in tests which expect it never to be used.
    z2This retrieve function expects to never be called!N)�RuntimeError��urirrr�blow_upsr/c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_S)`�TestRegistrycCs8tjddid�}d}t�j||d�}|||us4J�dS)zQ
        Adding a resource to the registry then allows re-retrieving it.
        �foo�barr�urn:example�r.rN)r�opaquer�
with_resource��selfrr.�registryrrr�test_with_resource#szTestRegistry.test_with_resourcecCsZtjid�}tdditd�}t��d|fd|fg�}|t�jd|d�jd|d�ksVJ�dS)	zT
        Adding multiple resources to the registry is like adding each one.
        rr1r2�r
r�http://example.com/1�http://example.com/foo/barr4N)rr5�ID_AND_CHILDRENr�with_resourcesr6�r8�one�twor9rrr�test_with_resources-s����z TestRegistry.test_with_resourcescCs8d}t�|dd��}|t�}|t��||�ks4J�dS)Nzurn:example:resource��r	r1)r>rrr6�r8r.rr9rrr�test_matmul_resourceBs
z!TestRegistry.test_matmul_resourcecCsZd}t�|dd��}d}t�|dd��}||gt�}|t��||f||fg�ksVJ�dS)Nzurn:example:onerDrEzurn:example:two)r>rrr?)r8Zone_urirAZtwo_urirBr9rrr�test_matmul_many_resourcesHs�z'TestRegistry.test_matmul_many_resourcescCs`tjddid�}t�tj��}|t�Wd�n1s<0Y|jtj|d�ks\J�dS)Nr1r2r�r)rr5�pytest�raisesrZNoInternalIDr�value)r8r�errr�test_matmul_resource_without_idTs(z,TestRegistry.test_matmul_resource_without_idcCs>d}ddi}t��||fg�}t|td�}|||ks:J�dS)Nr3�$schema�,https://json-schema.org/draft/2020-12/schemar;)r�
with_contentsrr)r8r.�schemar9�expectedrrr�#test_with_contents_from_json_schemaZs
z0TestRegistry.test_with_contents_from_json_schemacCs>d}t�j|ddifgtjd�}||t�ddi�ks:J�dS)Nr3r1r2�Zdefault_specification)rrQr�OPAQUErr5)r8r.r9rrr�,test_with_contents_and_default_specificationbs�z9TestRegistry.test_with_contents_and_default_specificationcCs8d}t�jdd�t|�D�tjd�}t|�|ks4J�dS)N�cSsg|]}t|�ddif�qS�r1r2��str�r�irrrrmrz)TestRegistry.test_len.<locals>.<listcomp>rU)rrQ�rangerrVr")r8�totalr9rrr�test_lenjs�zTestRegistry.test_lencCst�r
J�dS�N)r�r8rrr�test_bool_emptyrszTestRegistry.test_bool_emptycCs,t�jdd�td�D�tjd�}|s(J�dS)NcSsg|]}t|�ddif�qSrYrZr\rrrrwrz4TestRegistry.test_bool_not_empty.<locals>.<listcomp>�rU)rrQr^rrV�r8r9rrr�test_bool_not_emptyus
�z TestRegistry.test_bool_not_emptycCsBt�jdd�td�D�tjd�}t|�dd�td�D�ks>J�dS)NcSsg|]}t|�ddif�qSrYrZr\rrrr~rz*TestRegistry.test_iter.<locals>.<listcomp>�rUcSsh|]}t|��qSrrZr\rrr�	<setcomp>�rz)TestRegistry.test_iter.<locals>.<setcomp>)rrQr^rrV�setrerrr�	test_iter|s
�zTestRegistry.test_itercCs6t�ddi�}d}t||i���}|||us2J�dS�Nr1r2r3)rr5r�crawlr7rrr�'test_crawl_still_has_top_level_resource�sz4TestRegistry.test_crawl_still_has_top_level_resourcecCs�d}t�d|dd�gd��}|t�}t�t��||Wd�n1sN0Yt�|dd��}|��||ks|J�dS)N�	urn:child�urn:rootrDrE�r	r)r>rrrJrK�LookupErrorrl)r8Zchild_id�rootr9rSrrr�test_crawl_finds_a_subresource�s�
&z+TestRegistry.test_crawl_finds_a_subresourcecCsNt�dddid��}|t�}|���|��d�jtdt�d�d�ksJJ�dS)N�urn:barr1rD�r	rr)r>rrrl�anchor�idrLr�r8rr9rrr� test_crawl_finds_anchors_with_id�s�
�z-TestRegistry.test_crawl_finds_anchors_with_idcCsLt�dddii�}t��d|�}|���dd�jtdt�d�d�ksHJ�dS)Nrr1rDror)r>rrr6rlrvrLrrxrrr�test_crawl_finds_anchors_no_id�s�z+TestRegistry.test_crawl_finds_anchors_no_idcCs:t�ddi�}d}t��||�}|�|�ddiks6J�dSrk)rr5rr6r
r7rrr�
test_contents�szTestRegistry.test_contentscCsJd}t�d|di�}|t�}||||dkr@|ksFnJ�dS�N�http://example.com/r	�#)r>rrrFrrr�#test_getitem_strips_empty_fragments�s
z0TestRegistry.test_getitem_strips_empty_fragmentscCsVd}t�d|di�}|t�}|�|�|�|d�krLd|diksRnJ�dSr|)r>rrr
rFrrr�$test_contents_strips_empty_fragments�s
�
�z1TestRegistry.test_contents_strips_empty_fragmentscCsVt�}t�tj��}|�d�Wd�n1s20Y|jtjdd�ksRJ�dS)Nr3��ref)rrJrKr�NoSuchResourcer
rL�r8r9rMrrr�"test_contents_nonexistent_resource�s(z/TestRegistry.test_contents_nonexistent_resourcecCs^t�dddii�}t��d|�}|�dd�}|jtdt�d�d�ksHJ�|j|��ksZJ�dS)Nrr1r2r3r)	r>rrr6rvrLrr9rl)r8rr9Z	retrievedrrr�test_crawled_anchor�s�z TestRegistry.test_crawled_anchorcCsXt�}t�tj��}|�dd�Wd�n1s40Y|jtjdd�ksTJ�dS)Nr3r1r�)rrJrKrr�rvrLr�rrr�#test_anchor_in_nonexistent_resource�s*z0TestRegistry.test_anchor_in_nonexistent_resourcecCsPtjid�}t�ddi�}t||d��}|t��d|fd|fg���ksLJ�dS)Nrr1r2)r<r=r<r=)rr5r>rrr?rlr@rrr�	test_init�s������zTestRegistry.test_initcCsZtjid�}t�ddi�}td|i��d|�}|��t��d|fd|fg���ksVJ�dS)z�
        Passing a `dict` to `Registry` gets converted to a `HashTrieMap`.

        So continuing to use the registry works.
        rr1r2r<r=N)rr5r>rrr6rlr?r@rrr�test_dict_conversion�s������z!TestRegistry.test_dict_conversioncCsTt�}t�tj��}|dWd�n1s00Y|jtjdd�ksPJ�dS)Nzurn:bigboomr�)rrJrKrr�rLr�rrr�test_no_such_resources&z"TestRegistry.test_no_such_resourcec	
Cs�tjid�}t�ddi�}t�ddi�}t�dddii�}td|i�}t��d	|�}t||d
��}t��d|���}|�|||�td|fd|fd|fgtd
t	dt�d�d�i�d��d	|�ks�J�dS)Nrr1r2�baz�quuxrrDr<r=�r<�http://example.com/baz�http://example.com/foo/quuxr�)r�r1r)r)
rr5r>rrr6rl�combinerr)	r8rArB�threeZfour�first�second�third�fourthrrr�test_combines>����������zTestRegistry.test_combinecCs"tddi�}|�|�|usJ�dS)z�
        Combining a registry with itself short-circuits.

        This is a performance optimization -- otherwise we do lots more work
        (in jsonschema this seems to correspond to making the test suite take
         *3x* longer).
        �urn:foor2N)rr�rerrr�test_combine_self.s	zTestRegistry.test_combine_selfc	Cs�tjid�}t�ddi�}t�ddi�}t��d|�}t��d|�}t||d��}td|fd|fd	|fg�}|�||�}||ks�J�|��|ks�J�dS)
Nrr1r2r�r�r<r=r�r�)rr5r>rrr6r�rl)	r8rArBr�r�r�r�rSZcombinedrrr�%test_combine_with_uncrawled_resources:s&����z2TestRegistry.test_combine_with_uncrawled_resourcescCs�tjid�}t�ddi�}t�ddi�}dd�}t��d|�}t|d	��d
|�}t��d|�}|�||�t|d	��d|fd
|fd|fg�ks�J�|�||�t|d	��d|fd
|fd|fg�ks�J�dS)Nrr1r2r�r�cSsdSrarr-rrr�retrieveWsz@TestRegistry.test_combine_with_single_retrieve.<locals>.retriever<�r��http://example.com/2�http://example.com/3�rr5r>rrr6r�r?�r8rArBr�r�r�r�r�rrr�!test_combine_with_single_retrieveRs6�����
	���z.TestRegistry.test_combine_with_single_retrievecCs�tjid�}t�ddi�}t�ddi�}dd�}t|d��d	|�}t|d��d
|�}t|d��d|�}|�||�t|d��d	|fd
|fd|fg�ks�J�|�||�t|d��d	|fd
|fd|fg�ks�J�dS)Nrr1r2r�r�cSsdSrarr-rrrr�xsz@TestRegistry.test_combine_with_common_retrieve.<locals>.retriever�r<r�r�r�r�rrr�!test_combine_with_common_retrievessB
���
����
	���z.TestRegistry.test_combine_with_common_retrievec	Cs�tjid�}t�ddi�}t�ddi�}dd�}dd	�}t|d
��d|�}t��d|�}t|d
��d
|�}tjtdd��|�	||�Wd�n1s�0YdS)Nrr1r2r�r�cSsdSrarr-rrr�foo_retrieve�szDTestRegistry.test_combine_conflicting_retrieve.<locals>.foo_retrievecSsdSrarr-rrr�bar_retrieve�szDTestRegistry.test_combine_conflicting_retrieve.<locals>.bar_retriever�r<r�r�zconflict.*retriev��match)
rr5r>rrr6rJrK�	Exceptionr�)	r8rArBr�r�r�r�r�r�rrr�!test_combine_conflicting_retrieve�s 
�
�z.TestRegistry.test_combine_conflicting_retrievecCsFtjid�}t�ddi�}t||d��}|�d�td|i�ksBJ�dS)Nrr1r2)r�rtr�rt)rr5r>rr�remover@rrr�test_remove�szTestRegistry.test_removecCsRtjid�}t�ddi�}t��d|fd|fg�}|�d�t��d|�ksNJ�dS)Nrr1r2r�rt)rr5r>rrr?r�r6r@rrr�test_remove_uncrawled�s��z"TestRegistry.test_remove_uncrawledcCs^tjid�}t�dddii�}t��d|fd|fg���}|�d�t��d|���ksZJ�dS)Nrrr1r2r�rt)	rr5r>rrr?rlr�r6r@rrr�test_remove_with_anchors�s�����z%TestRegistry.test_remove_with_anchorscCsRt�tj��}t��d�Wd�n1s.0Y|jtjdd�ksNJ�dS)Nzurn:doesNotExistr�)rJrKrr�rr�rL)r8rMrrr�test_remove_nonexistent_uri�s*z(TestRegistry.test_remove_nonexistent_urics8t�ddi��t�fdd�d�}|�d�j�ks4J�dS)Nr1r2cs�Srarr-�r1rrr�rz,TestRegistry.test_retrieve.<locals>.<lambda>r�r3)rr5r�get_or_retrieverLrerr�r�
test_retrieve�szTestRegistry.test_retrievecsrt�ddi���fdd�}t|d�}|�d�j�ks8J�t�tj��|�d�Wd�n1sd0YdS)Nr1r2cs|dkr�Std��dS)N�urn:succeedzOh no!)r�r-r�rrr��sz@TestRegistry.test_retrieve_arbitrary_exception.<locals>.retriever�r��urn:uhoh)	rr5rr�rLrJrKr�
Unretrievable�r8r�r9rr�r�!test_retrieve_arbitrary_exception�s
z.TestRegistry.test_retrieve_arbitrary_exceptioncsrt�ddi���fdd�}t|d�}|�d�j�ks8J�t�tj��|�d�Wd�n1sd0YdS)Nr1r2cs|dkr�Stj|d��dS)Nr�r�)rr�r-r�rrr��sz=TestRegistry.test_retrieve_no_such_resource.<locals>.retriever�r�r�)	rr5rr�rLrJrKrr�r�rr�r�test_retrieve_no_such_resource�s
z+TestRegistry.test_retrieve_no_such_resourcecCsLdd�}t|d�}t�tj��|�d�Wd�n1s>0YdS)NcSs
t�i�Sra)r�
from_contentsr-rrrr��szKTestRegistry.test_retrieve_cannot_determine_specification.<locals>.retriever�r�)rrJrKr�CannotDetermineSpecificationr�r�rrr�,test_retrieve_cannot_determine_specification�s
z9TestRegistry.test_retrieve_cannot_determine_specificationcCsFt�ddi�}td|itd�}|d|ks.J�|�d�j|ksBJ�dS)Nr1r2r3r�)rr5rr/r�rL)r8r1r9rrr�(test_retrieve_already_available_resourcesz5TestRegistry.test_retrieve_already_available_resourcecCsLt�ddd��}t�d|jgi�}ttd��d|�}|��d|ksHJ�dS)NrnrDrErr�ro)r>rr
rr/r6rl)r8�childrrr9rrr�-test_retrieve_first_checks_crawlable_resource	sz:TestRegistry.test_retrieve_first_checks_crawlable_resourcecCs<tjid�}td|i�}|jdd�}|�d�jiks8J�dS)Nr�http://example.com)Zbase_urir~�rr5rr'�lookupr
)r8rAr9r'rrr�
test_resolverszTestRegistry.test_resolvercCsJt�ddi�}t��|�}|�d�j|jks0J�|�d�j|jksFJ�dS)Nr	r�r~)r>rr�resolver_with_rootr�r
�r8rrr'rrr�"test_resolver_with_root_identifiedsz/TestRegistry.test_resolver_with_root_identifiedcCs2tjid�}t��|�}|�d�j|jks.J�dS)Nrr~)rr5rr�r�r
r�rrr�$test_resolver_with_root_unidentifiedsz1TestRegistry.test_resolver_with_root_unidentifiedcCsZtjid�}t�ddi�}t��d|fd|fg�}t|�dksBJ�t|���dksVJ�dS)Nrr1r2r<r=z"<Registry (2 uncrawled resources)>z<Registry (2 resources)>)rr5r>rrr?�reprrlr@rrr�	test_repr s��zTestRegistry.test_reprcCsHtjid�}t�ddi�}td|i���jd|d�}t|�dksDJ�dS)Nrr1r2r<r=r4z%<Registry (2 resources, 1 uncrawled)>)rr5r>rrrlr6r�r@rrr�test_repr_mixed_crawled,s���z$TestRegistry.test_repr_mixed_crawledcCs,t�jdtjid�d�}t|�dks(J�dS)Nr<rr4z!<Registry (1 uncrawled resource)>)rr6rr5r�rerrr�test_repr_one_resource8s

�z#TestRegistry.test_repr_one_resourcecCstt��dksJ�dS)Nz<Registry (0 resources)>)r�rrbrrr�test_repr_empty?szTestRegistry.test_repr_emptyN)2�__name__�
__module__�__qualname__r:rCrGrHrNrTrWr`rcrfrjrmrsryrzr{rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr0"s^
	

&!'

r0c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �TestResourcecCs*ddi}t�|�}|t|td�ks&J�dS)NrOrPr;)rr�r�r8rRrrrr�#test_from_contents_from_json_schemaDs
z0TestResource.test_from_contents_from_json_schemacCs>t�tj��t�ddi�Wd�n1s00YdS)z�
        Creating a resource with no discernible way to see what
        specification it belongs to (e.g. no ``$schema`` keyword for JSON
        Schema) raises an error.
        r1r2N)rJrKrr�rr�rbrrr�2test_from_contents_with_no_discernible_informationIsz?TestResource.test_from_contents_with_no_discernible_informationcCs0tjdditjd�}|tjddid�ks,J�dS�Nr1r2rUr�rr�rrVr5�r8rrrr�>test_from_contents_with_no_discernible_information_and_defaultSs
�zKTestResource.test_from_contents_with_no_discernible_information_and_defaultcCs0ddi}tj|tjd�}|t|td�ks,J�dS)NrOrPrUr;)rr�rrVrr�rrr�#test_from_contents_unneeded_defaultZs��z0TestResource.test_from_contents_unneeded_defaultcCs&tjdtd�}|tdtd�ks"J�dS)NTrUr;)rr�r>r�rrr�test_non_mapping_from_contentses��z+TestResource.test_non_mapping_from_contentscCs0tjdditjd�}|tjddid�ks,J�dSr�r�r�rrr� test_from_contents_with_fallbackos
�z-TestResource.test_from_contents_with_fallbackcCsFtddd�dd�dd�dd�d�}tdd	i|d
�}|��dksBJ�dS)N�cSsdS�N�urn:fixedIDrrrrrryrzATestResource.test_id_delegates_to_specification.<locals>.<lambda>cSsgSrarrrrrrzrcSsgSrarrrrrr{rcSs|Srarr%rrrr}rr(r1r�r;r�)rrrw�r8rrrrr�"test_id_delegates_to_specificationvs�	�z/TestResource.test_id_delegates_to_specificationcCs*d}t�d|di�}|��|ks&J�dSr|)r>rrw)r8r.rrrrr�test_id_strips_empty_fragment�sz*TestResource.test_id_strips_empty_fragmentcCs8t�didgi�}t|���dd�idfD�ks4J�dS)NrrDcSsg|]}t�|��qSr)r>rr rrrr�szMTestResource.test_subresources_delegates_to_specification.<locals>.<listcomp>)r>r�list�subresourcesr�rrr�,test_subresources_delegates_to_specification�s�z9TestResource.test_subresources_delegates_to_specificationcCs8ddi}t�d|gi�}t|���t�|�gks4J�dS)NrOrPr)r>rr�r�rr�rrr�-test_subresource_with_different_specification�s

�z:TestResource.test_subresource_with_different_specificationcCs^t�diddd�i�}t|���tdt�i�d�tdt�d�d�tdt�d�d�gksZJ�dS)	Nr�r�)r1r2r�r1rr2r�)r>rr�rrr�rrr�'test_anchors_delegates_to_specification�s�
�z4TestResource.test_anchors_delegates_to_specificationcCs6tjddid�}t���}|jd|d�jdks2J�dS)Nr1r�rz/foo�r'�rr5rr'�pointerr
�r8rr'rrr�test_pointer_to_mapping�s
z$TestResource.test_pointer_to_mappingcCs<tjdddgiid�}t���}|jd|d�jdks8J�dS)Nr1r2rdrz
/foo/bar/0r�r�r�rrr�test_pointer_to_array�s
z"TestResource.test_pointer_to_arraycCs:ddi}tj|d�}t���}|jd|d�j|ks6J�dS)Nr1r�rr�r�r�)r8r
rr'rrr�test_root_pointer�s
zTestResource.test_root_pointercCs(ddi}t�|�t|tjd�ks$J�dS)Nr1r2r;)rr5rrV)r8r
rrr�test_opaque�s

�zTestResource.test_opaqueN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�Cs


r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�TestResolvercCs>tjddid�}td|i���}|�d�}|j|jks:J�dS)Nr1r�rr<r�)r8rr'�resolvedrrr�test_lookup_exact_uri�s
z"TestResolver.test_lookup_exact_uricCsHt�dddd�gd��}|t�}|���d�}|jddd�ksDJ�dS)Nr}zhttp://example.com/arDrErp�r>rrr'r�r
�r8rrr9r�rrr�test_lookup_subresource�s���
z$TestResolver.test_lookup_subresourcecCs>t�dddid��}|t�}|���d�}|jdks:J�dS)Nr}r1rDruzhttp://example.com/#foor�r�rrr�test_lookup_anchor_with_id�s��
z'TestResolver.test_lookup_anchor_with_idcCs@t�dddii�}t��d|���}|�d�}|jdks<J�dS)Nrr1rDr3zurn:example#foo)r>rrr6r'r�r
)r8rrr'r�rrr�test_lookup_anchor_without_id�s
z*TestResolver.test_lookup_anchor_without_idcCs^t���}d}t�tj��}|�|�Wd�n1s:0Y|jtj|d�ksZJ�dS)Nz!http://example.com/does/not/existr�)rr'rJrKr�Unresolvabler�rL)r8r'r�rMrrr�test_lookup_unknown_reference�s

(z*TestResolver.test_lookup_unknown_referencecCs�t�dii�}td|i���}d}t�tj��}|�|�Wd�n1sN0Y|j	tj
d|d�kspJ�t|j	�dks�J�dS)Nr1r<zhttp://example.com/1#/foo/barz/foo/bar�r�rz,'/foo/bar' does not exist within {'foo': {}})rr5rr'rJrKrr�r�rL�PointerToNowherer[�r8rr'r�rMrrr� test_lookup_non_existent_pointer�s(�z-TestResolver.test_lookup_non_existent_pointercCstt�gd��}td|i���}d}t�tj��}|�|�Wd�n1sN0Y|j	tj
d|d�kspJ�dS)N)r�r�rgr<zhttp://example.com/1#/10z/10r�)rr5rr'rJrKrr�r�rLr�r�rrr�/test_lookup_non_existent_pointer_to_array_index�s(�z<TestResolver.test_lookup_non_existent_pointer_to_array_indexcCs.t��t�dii��}|�d�jiks*J�dS)Nr��#/)rr�rr5r�r
)r8r'rrr�#test_lookup_pointer_to_empty_string�sz0TestResolver.test_lookup_pointer_to_empty_stringcCspt�dii�}t��|�}tjtjdd��}|�d�Wd�n1sJ0Y|j	tj
d|d�kslJ�dS)Nr1z+^'/' does not exist within {'foo': {}}.*'#'r�r��/r�)rr5rr�rJrKrr�r�rLr�)r8rr'rMrrr�0test_lookup_non_existent_pointer_to_empty_strings�(�z=TestResolver.test_lookup_non_existent_pointer_to_empty_stringcCs�t�dii�}t��d|���}|�d�}|j|jks:J�d}t�t	j
��}|�|�Wd�n1sj0Ydt|j�vs�J�|jt	j
d|dd�ks�J�dS)Nrr3zurn:example#noSuchAnchorz'noSuchAnchor' does not existZnoSuchAnchor)r�rrv)r>rrr6r'r�r
rJrKrr�r[rLZNoSuchAnchor)r8rrr'r�r�rMrrr�test_lookup_non_existent_anchors
(�z,TestResolver.test_lookup_non_existent_anchorcCs�t��t�dddid���}|�d�}|jdks4J�t�tj	��}|�d�Wd�n1s`0Ydt
|j�vs|J�dS)Nr}r2rDrEz	#/foo/barz#foo/barz '#/foo/bar')rr�r>rr�r
rJrKrZ
InvalidAnchorr[rL)r8r'ZvalidrMrrr�*test_lookup_invalid_JSON_pointerish_anchors���	
(z7TestResolver.test_lookup_invalid_JSON_pointerish_anchorcsDtjddid��t�fdd�d���}|�d�}|j�jks@J�dS)Nr1r�rcs�Srarr-rIrrr1rz=TestResolver.test_lookup_retrieved_resource.<locals>.<lambda>r�r}r�)r8r'r�rrIr�test_lookup_retrieved_resource/s
z+TestResolver.test_lookup_retrieved_resourcecCs�d}ttd�}t�tj��|�|�Wd�n1s:0Y|��}t�tj��|�	|�Wd�n1sx0YdS)zL
        Unretrievable exceptions are also wrapped in Unresolvable.
        r}r�N)
rr/rJrKrr�r�r'r�r�)r8r.r9r'rrr�%test_lookup_failed_retrieved_resource5s
(z2TestResolver.test_lookup_failed_retrieved_resourcecsjtjddid�}|g��fdd�}t|d���}|�d�}|j|jksJJ�|j�d�}|j|jksfJ�dS)	zk
        A (custom-)retrieved resource is added to the registry returned by
        looking it up.
        r1r�rcs���Sra��popr-��oncerrr�LszKTestResolver.test_repeated_lookup_from_retrieved_resource.<locals>.retriever�r}Nr��r8rr�r'r�rrr�,test_repeated_lookup_from_retrieved_resourceDs
z9TestResolver.test_repeated_lookup_from_retrieved_resourcecsjtjddid�}|g��fdd�}t|d���}|�d�}|j|jksJJ�|j�d�}|j|jksfJ�dS)	Nr1r�rcs���Srarr-rrrr�ZszRTestResolver.test_repeated_anchor_lookup_from_retrieved_resource.<locals>.retriever�r}r~r�rrrr�3test_repeated_anchor_lookup_from_retrieved_resourceVs
z@TestResolver.test_repeated_anchor_lookup_from_retrieved_resourcecCs�t�ddddigd�gd��}|t�}|��}|�d�}|j|jksJJ�t�tj	��|j�d�Wd�n1sx0Y|j�
t�|jdd��}|�d�}|jddiks�J�dS)Nr}�child/r	�
grandchildrprr)r>rrr'r�r
rJrKrr�r$)r8rrr9r'r��subr�rrr�test_in_subresourcegs&����

*�
z TestResolver.test_in_subresourcecCs�t�ddddigd�gd��}|t�}|��}|�d�}|j|jksJJ�t�tj	��|j�d�Wd�n1sx0Y|j�d�}|j�d�}|jddiks�J�dS)Nr}r
r	rrp�#/children/0)
r>rrr'r�r
rJrKrr�)r8rrr9r'r�r�r�rrr�test_in_pointer_subresource�s"����

*z(TestResolver.test_in_pointer_subresourcec	Cst�ddddigd�gd��}t�dddigd��}||gt�}|��}|�d�}|j�d�}|j�d�}|j�d�}t|j���d	|jjfd
|jjfd|jjfgks�J�t|j���d
|jjfd|jjfgks�J�t|j���d|jjfgks�J�t|j���gk�sJ�dS)Nr}r
r	rrpzhttp://example.com/twoz
two-child/rz#http://example.com/child/grandchildzhttp://example.com/child/)r>rrr'r�r�Z
dynamic_scope�	_registry)	r8rArBr9r'r�r�r�r�rrr�test_dynamic_scope�s@������



�


�

�
zTestResolver.test_dynamic_scopeN)r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr	r
rrrrrrr��s$

r�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestSpecificationcCs^tddd�dd�dd�dd�d�}|jdd	id
�}|tdd	i|d�ksJJ�|��dksZJ�dS)
Nr�cSsdSr�rrrrrr�rz8TestSpecification.test_create_resource.<locals>.<lambda>cSsgSrarrrrrr�rcSsgSrarrrrrr�rcSs|Srarr%rrrr�rr(r1r�rr;r�)rrrrwr�rrr�test_create_resource�s�	�z&TestSpecification.test_create_resourcecCs"ddi}t�|�}|tksJ�dS�NrOrP)r�detectr�r8rRrrrr�test_detect_from_json_schema�s
z.TestSpecification.test_detect_from_json_schemacCs>t�tj��t�ddi�Wd�n1s00YdS�Nr1r2�rJrKrr�rrrbrrr�+test_detect_with_no_discernible_information�sz=TestSpecification.test_detect_with_no_discernible_informationcCs>t�tj��t�ddi�Wd�n1s00YdS)NrO�%rrbrrr�test_detect_with_non_URI_schema�sz1TestSpecification.test_detect_with_non_URI_schemacCs"tj�ddi�}|tjusJ�dSr�rrVr�r8rrrr�7test_detect_with_no_discernible_information_and_default�szITestSpecification.test_detect_with_no_discernible_information_and_defaultcCs$ddi}tj�|�}|tks J�dSr)rrVrrrrrr�test_detect_unneeded_default�sz.TestSpecification.test_detect_unneeded_defaultcCs:t�tj��t�d�Wd�n1s,0YdS�NTrrbrrr�test_non_mapping_detect�sz)TestSpecification.test_non_mapping_detectcCst�d�}|tusJ�dSr!)r>rrrrr�$test_non_mapping_detect_with_default�s
z6TestSpecification.test_non_mapping_detect_with_defaultcCs"tj�ddi�}|tjusJ�dSrrrrrr�test_detect_with_fallback�sz+TestSpecification.test_detect_with_fallbackcCstt�dksJ�dS)Nz&<Specification name='id-and-children'>)r�r>rbrrrr��s
�zTestSpecification.test_reprN)
r�r�r�rrrrrr r"r#r$r�rrrrr�src@sbeZdZddiddde�gZej�de�dd��Zej�de�dd	��Z	ej�de�d
d��Z
dS)
�TestOpaqueSpecificationr1r2Tr�thingcCstj�|�dusJ�dS)z/
        An arbitrary thing has no ID.
        N)rrVr)�r8r&rrr�
test_no_idsz"TestOpaqueSpecification.test_no_idcCsttj�|��gksJ�dS)z9
        An arbitrary thing has no subresources.
        N)r�rrVr*r'rrr�test_no_subresourcessz,TestOpaqueSpecification.test_no_subresourcescCsttj�|��gksJ�dS)z4
        An arbitrary thing has no anchors.
        N)r�rrVr+r'rrr�test_no_anchorssz'TestOpaqueSpecification.test_no_anchorsN)r�r�r��objectZTHINGSrJ�mark�parametrizer(r)r*rrrrr%�s

r%�clscCsBtjtdd�� Gdd�d|�}Wd�n1s40YdS)Nz(?i)subclassingr�c@seZdZdS)z"test_nonsubclassable.<locals>.BoomN)r�r�r�rrrr�Boom sr/)rJrKr�)r.r/rrr�test_nonsubclassablesr0)ZrpdsrrJZreferencingrrrrrZreferencing.jsonschemarr>r/r0r�r�rr%r,r-r�r0rrrr�<module>s6�%w:�