
    $go$                         d dl Z d dlmZ ddlmZmZmZmZmZm	Z	m
Z
mZ ddlmZmZmZmZmZ ddlmZ  G d d	e	          Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"dS )    N)raises   )ArgumentFieldIntListNonNull
ObjectTypeSchemaString   )
ConnectionConnectionFieldPageInfoConnectionOptionsget_edge_class)Nodec                   <    e Zd Z G d d          Z e            ZdS )MyObjectc                       e Zd ZegZdS )MyObject.MetaN)__name__
__module____qualname__r   
interfaces     d/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/graphene/relay/tests/test_connection.pyMetar      s        V


r   r   N)r   r   r   r   r   fieldr   r   r   r   r      sC                FHHEEEr   r   c                  *    G d dt                     } | j        j        dk    sJ | j        j        }t	          |          g dk    sJ |d         }|d         }t          |t                    sJ t          |j        t                    sJ t          |j        j	        t                    sJ |j        j	        j	        | j        k    sJ t          |t                    sJ t          |j        t                    sJ |j        j	        t          k    sJ d S )Nc                   V    e Zd Z e            Z G d d          Z G d d          ZdS )+test_connection.<locals>.MyObjectConnectionc                       e Zd ZeZdS )0test_connection.<locals>.MyObjectConnection.MetaNr   r   r   r   noder   r   r   r   r%              DDDr   r   c                   "    e Zd Z e            ZdS )0test_connection.<locals>.MyObjectConnection.EdgeNr   r   r   r   otherr   r   r   Edger*              FHHEEEr   r-   N)r   r   r   r   extrar   r-   r   r   r   MyObjectConnectionr#      so        	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	r   r0   	page_infoedgesr/   r3   r2   )r   _metanamefieldslist
isinstancer   typer	   of_typer   r-   r   )r0   r6   
edge_fieldpageinfo_fields       r   test_connectionr=      s4       Z    #(,@@@@@%,F<<:::::::JK(Nj%(((((jow/////jo-t44444?"*.@.EEEEEne,,,,,n)733333&(222222r   c                       G d d          }  G d d| t                     }|j        j        dk    sJ |j        j        }t	          |          g dk    sJ d S )Nc                   "    e Zd Z e            ZdS )<test_connection_inherit_abstracttype.<locals>.BaseConnectionNr   r   r   r   r/   r   r   r   BaseConnectionr@   2           r   rB   c                   (    e Zd Z G d d          ZdS )@test_connection_inherit_abstracttype.<locals>.MyObjectConnectionc                       e Zd ZeZdS )Etest_connection_inherit_abstracttype.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   rG   6   r(   r   r   Nr   r   r   r   r   r   r   r0   rE   5   <        	 	 	 	 	 	 	 	 	 	r   r0   r1   )r   r4   r5   r6   r7   )rB   r0   r6   s      r   $test_connection_inherit_abstracttyperJ   1   s               ^Z    #(,@@@@@%,F<<:::::::::r   c                  <    G fddt                      G d d          } | j        j        dk    sJ | j        j        }t	          |          g dk    sJ |d         }|d         }|d         }t          |t                    sJ t          |j        t                    sJ t          |j        j	        t                    sJ |j        j	        j	        | j        k    sJ t          |t                    sJ t          |j        t                    sJ |j        j	        t          k    sJ t          |t                    sJ t          |j        t                    sJ t          |j        j	        t                    sJ |j        j	        j	        t          k    sJ d S )	Nc                   N     e Zd Z G d d          Zed fd	            Z xZS )Btest_connection_extra_abstract_fields.<locals>.ConnectionWithNodesc                       e Zd ZdZdS )Gtest_connection_extra_abstract_fields.<locals>.ConnectionWithNodes.MetaTNr   r   r   abstractr   r   r   r   rO   @           HHHr   r   Nc                     t          |           }dt          t          t          |                    d          i|_         t          |           j        d|||d|S )Nnodesz*Contains all the nodes in this connection.descriptionr'   r5   r4   r   )r   r   r	   r   r6   super__init_subclass_with_meta__)clsr'   r5   optionsr4   ConnectionWithNodes	__class__s        r   rY   z^test_connection_extra_abstract_fields.<locals>.ConnectionWithNodes.__init_subclass_with_meta__C   s    %c**E DJJ'' L  EL O5,c22N E 5<  r   NNr   r   r   r   classmethodrY   __classcell__r]   r\   s   @r   r\   rM   ?   sw        	 	 	 	 	 	 	 	 
	 	 	 	 	 	 
	 	 	 	 	r   r\   c                   B    e Zd Z G d d          Z G d d          ZdS )Atest_connection_extra_abstract_fields.<locals>.MyObjectConnectionc                       e Zd ZeZdS )Ftest_connection_extra_abstract_fields.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   rf   S   r(   r   r   c                   "    e Zd Z e            ZdS )Ftest_connection_extra_abstract_fields.<locals>.MyObjectConnection.EdgeNr+   r   r   r   r-   rh   V   r.   r   r-   Nr   r   r   r   r-   r   r   r   r0   rd   R   d        	 	 	 	 	 	 	 		 	 	 	 	 	 	 	 	 	r   r0   )rT   r2   r3   r3   r2   rT   )r   r4   r5   r6   r7   r8   r   r9   r	   r:   r   r-   r   r   )r0   r6   r;   r<   nodes_fieldr\   s        @r   %test_connection_extra_abstract_fieldsrl   >   s         j   &    0    #(,@@@@@%,F<<:::::::JK(N/Kj%(((((jow/////jo-t44444?"*.@.EEEEEne,,,,,n)733333&(2222k5)))))k&00000k&.55555#+x777777r   c                      G fddt                      G d d          } | j        j        dk    sJ | j        j        }t	          |          ddgk    sJ |d         }|d         }t          |t                    sJ t          |j        t                    sJ t          |j        j	        t                    sJ t          |j        j	        j	        t                    sJ |j        j	        j	        j	        j        dk    sJ t          |t                    sJ t          |j        t                    sJ |j        j	        t          k    sJ d S )Nc                   N     e Zd Z G d d          Zed fd	            Z xZS )<test_connection_override_fields.<locals>.ConnectionWithNodesc                       e Zd ZdZdS )Atest_connection_override_fields.<locals>.ConnectionWithNodes.MetaTNrP   r   r   r   r   rq   q   rR   r   r   Nc           
         t          |           }t          j        dd|p| j                  p|j        j        }t          | ||          }t          t          t          ddd                    t          t          t          t          |                              d          d	|_         t          |           j        d|||d
|S )NzConnection$ pageInfoTz$Pagination data for this connection.)r5   requiredrV   z&Contains the nodes in this connection.rU   )r2   r3   rW   r   )r   resubr   r4   r5   r   r   r	   r   r   r6   rX   rY   )	rZ   r'   r5   r[   r4   	base_name
edge_classr\   r]   s	          r   rY   zXtest_connection_override_fields.<locals>.ConnectionWithNodes.__init_subclass_with_meta__t   s    %c**E}b$*>#,??R4:?  (T9==J # '!%$J	    D!4!45566 H   EL O5,c22N E 5<  r   r^   r_   rb   s   @r   r\   ro   p   sw        	 	 	 	 	 	 	 	 
	 	 	 	 	 	 
	 	 	 	 	r   r\   c                   (    e Zd Z G d d          ZdS );test_connection_override_fields.<locals>.MyObjectConnectionc                       e Zd ZeZdS )@test_connection_override_fields.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r}      r(   r   r   NrH   r   r   r   r0   r{      rI   r   r0   r2   r3   MyObjectEdge)r   r4   r5   r6   r7   r8   r   r9   r	   r:   r   r   r   )r0   r6   r;   r<   r\   s       @r   test_connection_override_fieldsr   o   s         j   @    0    #(,@@@@@%,F<<K11111JK(Nj%(((((jow/////jo-t44444jo-5w??????"*2;~MMMM ne,,,,,jow/////&(222222r   c                  v    d G d d          }  G fdd| t                     }|j        j        k    sJ d S )NMyObjectCustomNameConnectionc                   "    e Zd Z e            ZdS ),test_connection_name.<locals>.BaseConnectionNrA   r   r   r   rB   r      rC   r   rB   c                   .    e Zd Z G  fdd          ZdS )0test_connection_name.<locals>.MyObjectConnectionc                       e Zd ZeZ ZdS )5test_connection_name.<locals>.MyObjectConnection.MetaN)r   r   r   r   r'   r5   custom_names   r   r   r      s        DDDDr   r   NrH   r   s   r   r0   r      sG        	 	 	 	 	 	 	 	 	 	 	 	r   r0   )r   r4   r5   )rB   r0   r   s     @r   test_connection_namer      s    0K             ^Z   
 #(K777777r   c                  x    G d dt                     } | j        }|j        j        dk    sJ |j        j        }t          |          g dk    sJ t          |d         t                    sJ |d         j        t          k    sJ t          |d         t                    sJ |d         j        t          k    sJ d S )Nc                   B    e Zd Z G d d          Z G d d          ZdS )%test_edge.<locals>.MyObjectConnectionc                       e Zd ZeZdS )*test_edge.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r      r(   r   r   c                   "    e Zd Z e            ZdS )*test_edge.<locals>.MyObjectConnection.EdgeNr+   r   r   r   r-   r      r.   r   r-   Nri   r   r   r   r0   r      rj   r   r0   r~   )r'   cursorr,   r'   r,   r   r-   r4   r5   r6   r7   r8   r   r9   r   r   )r0   r-   edge_fieldss      r   	test_edger      s        Z    "D:?n,,,,*#K ; ; ;;;;;k&)511111v#x////k'*E22222w$......r   c                      G d d           G fddt                     } | j        }|j        j        dk    sJ |j        j        }t          |          g dk    sJ t          |d         t                    sJ |d         j        t          k    sJ t          |d         t                    sJ |d         j        t          k    sJ d S )	Nc                   "    e Zd Z e            ZdS )&test_edge_with_bases.<locals>.BaseEdgeNrA   r   r   r   BaseEdger      rC   r   r   c                   F    e Zd Z G d d          Z G d d           ZdS )0test_edge_with_bases.<locals>.MyObjectConnectionc                       e Zd ZeZdS )5test_edge_with_bases.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r      r(   r   r   c                   "    e Zd Z e            ZdS )5test_edge_with_bases.<locals>.MyObjectConnection.EdgeNr+   r   r   r   r-   r      r.   r   r-   Nri   )r   s   r   r0   r      sg        	 	 	 	 	 	 	 		 	 	 	 	8 	 	 	 	 	r   r0   r~   )r'   r   r/   r,   r'   r,   r   )r0   r-   r   r   s      @r   test_edge_with_basesr      s                Z    "D:?n,,,,*#K D D DDDDDk&)511111v#x////k'*E22222w$......r   c                      G d dt                     } | j        j        j        }t	          |d         t
                    sJ t	          |d         j        t                    sJ |d         j        j        t          k    sJ d S )Nc                   (    e Zd Z G d d          ZdS )7test_edge_with_nonnull_node.<locals>.MyObjectConnectionc                   $    e Zd Z ee          ZdS )<test_edge_with_nonnull_node.<locals>.MyObjectConnection.MetaN)r   r   r   r	   r   r'   r   r   r   r   r      s        78$$DDDr   r   NrH   r   r   r   r0   r      s<        	% 	% 	% 	% 	% 	% 	% 	% 	% 	%r   r0   r'   )
r   r-   r4   r6   r8   r   r9   r	   r:   r   )r0   r   s     r   test_edge_with_nonnull_noder      s    % % % % %Z % % % %)/6Kk&)511111k&).88888v#+x777777r   c                      t           j        j        dk    sJ t           j        j        } t	          |           g dk    sJ d S )Nr   )has_next_pagehas_previous_pagestart_cursor
end_cursor)r   r4   r5   r6   r7   )r6   s    r   test_pageinfor      sX    >*,,,,^"F<<         r   c                       G d dt                     } t          |           }|j        t          t                    t          t                    t          t
                    t          t
                    dk    sJ d S )Nc                   (    e Zd Z G d d          ZdS )0test_connectionfield.<locals>.MyObjectConnectionc                       e Zd ZeZdS )5test_connectionfield.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r      r(   r   r   NrH   r   r   r   r0   r      rI   r   r0   )beforeafterfirstlast)r   r   argsr   r   r   r0   r    s     r   test_connectionfieldr      s        Z    .//E:6""&!!#	       r   c                      t          t                    } t          t                    5 }| j         d d d            n# 1 swxY w Y   dt          |j                  v sJ d S )Nz>ConnectionFields now need a explicit ConnectionType for Nodes.)r   r   r   	Exceptionr9   strvalue)r    exc_infos     r   $test_connectionfield_node_deprecatedr     s    H%%E				 h

               LsP P      s   =AAc                  x    G d dt                     } t          | t          d          t                                }|j        t	          t          t                              t	          t                    t	          t                    t	          t                    t	          t                    dk    sJ d S )Nc                   (    e Zd Z G d d          ZdS )<test_connectionfield_custom_args.<locals>.MyObjectConnectionc                       e Zd ZeZdS )Atest_connectionfield_custom_args.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r     r(   r   r   NrH   r   r   r   r0   r     rI   r   r0   Tru   )r   r/   )r   r   r   r   r/   )r   r   r   r   r   r	   r   r   s     r    test_connectionfield_custom_argsr     s        Z    64#8#8#8  E :76??++&!!#&!!       r   c                       G d dt                      G fddt                    } t          |           }|                    d          }|j        rJ |j        ddg iik    sJ d S )	Nc                   (    e Zd Z G d d          ZdS )9test_connectionfield_required.<locals>.MyObjectConnectionc                       e Zd ZeZdS )>test_connectionfield_required.<locals>.MyObjectConnection.MetaNr&   r   r   r   r   r   !  r(   r   r   NrH   r   r   r   r0   r      rI   r   r0   c                   0    e Zd Z e d          Zd ZdS ),test_connectionfield_required.<locals>.QueryTr   c                     g S )Nr   )rootinfor   s      r   resolve_test_connectionzDtest_connectionfield_required.<locals>.Query.resolve_test_connection'  s    Ir   N)r   r   r   r   r=   r   )r0   s   r   Queryr   $  s9        )/*<tLLL	 	 	 	 	r   r   )queryz'{ testConnection { edges { cursor } } }testConnectionr3   )r   r
   r   executeerrorsdata)r   schemaexecutedr0   s      @r   test_connectionfield_requiredr     s        Z         
    %   F~~GHHH=-}=======r   c                  \    G d dt                     } t          |           }|j        j        j        d         j        }t          |t                    sJ |j        j        }t          |t                    sJ |j        j        j        d         }t          |j        t                    sJ d S )Nc                   (    e Zd Z G d d          ZdS )=test_connectionfield_strict_types.<locals>.MyObjectConnectionc                       e Zd ZeZdZdS )Btest_connectionfield_strict_types.<locals>.MyObjectConnection.MetaTN)r   r   r   r   r'   strict_typesr   r   r   r   r   2  s        DLLLr   r   NrH   r   r   r   r0   r   1  s<        	  	  	  	  	  	  	  	  	  	 r   r0   r3   r'   )r   r   r9   r4   r6   r8   r	   r:   )r0   connection_fieldedges_field_typeedges_list_element_type
node_fields        r   !test_connectionfield_strict_typesr   0  s             Z      
 ''9::',29'BG&00000.6>-w77777(06=fEJjow///////r   )#rv   pytestr   typesr   r   r   r   r	   r
   r   r   
connectionr   r   r   r   r   r'   r   r   r=   rJ   rl   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s   				       T T T T T T T T T T T T T T T T T T T T                       z   3 3 34
; 
; 
;.8 .8 .8b53 53 53p8 8 8/ / /(/ / /.8 8 8        "> > >"0 0 0 0 0r   