
    i2;                        d Z dZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ dZ G d dej                         Z G d dej                         Zedk(  r ej(                          yy)zUnittest that directly tests the output of the pure-Python protocol
compiler.  See //google/protobuf/internal/reflection_test.py for a test which
further ensures that we can use Python protocol message objects as we expect.
z#robinson@google.com (Will Robinson)    N)test_bad_identifiers_pb2)unittest_custom_options_pb2)unittest_import_pb2)unittest_import_public_pb2)unittest_mset_pb2)unittest_mset_wire_format_pb2) unittest_no_generic_services_pb2)unittest_pb2)service)symbol_databasei    c                       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 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)GeneratorTestc                     d}t         j                  }| j                  |j                  j                  |j                  j
                  |   j                         y )Noptional_nested_message)r
   TestAllTypesassertEqualNestedMessage
DESCRIPTORfields_by_namemessage_type)self
field_name
proto_types      y/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/google/protobuf/internal/generator_test.pytestNestedMessageDescriptorz)GeneratorTest.testNestedMessageDescriptor<   sJ    *J**J  ++,,Z8EEG    c                    | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         t        j
                         }| j                  d|j                         | j                  dt        j
                  j                         | j                  d|j                         | j                  dt        j
                  j                         | j                  d|j                         | j                  dt        j
                  j                         y )N                  )	r   r
   FOREIGN_FOOFOREIGN_BARFOREIGN_BAZr   FOOBARBAZr   protos     r   	testEnumszGeneratorTest.testEnumsC   s     	Q001Q001Q001%%'EQ		"Q11556Q		"Q11556Q		"Q11556r   c                    t        j                         }d fd}| j                   ||j                               | j                  |j                  dkD         | j                   ||j                               | j                  |j                  dk         | j                   |j
                               | j                   ||j                               | j                  |j                  dkD         | j                   ||j                               | j                  |j                  dk         | j                   |j                               | j                  d|j                         y )Nc                     | | k7  S N )vals    r   isnanz5GeneratorTest.testExtremeDefaultValues.<locals>.isnanX   s    CZr   c                 0     |        xr  | dz        S Nr   r0   )r1   r2   s    r   isinfz5GeneratorTest.testExtremeDefaultValues.<locals>.isinf[   s    s^.cAg.r   r   z? ? ?? ?? ??? ??/ ??-)r
   TestExtremeDefaultValues
assertTrue
inf_doubleneg_inf_double
nan_double	inf_floatneg_inf_float	nan_floatr   cpp_trigraph)r   messager5   r2   s      @r   testExtremeDefaultValuesz&GeneratorTest.testExtremeDefaultValuesS   s   335G/ 	OOE',,-.OOG&&*+OOE'0012OOG**Q./OOE',,-.OOE'++,-OOG%%)*OOE'//01OOG))A-.OOE'++,-,g.B.BCr   c                    t         j                  j                  }ddddd}t        |j                  D cg c](  }|j
                  |v r|j
                  |j                  f* c}      }| j                  ||       y c c}w )NFT)optional_int32repeated_int32r   default_int32)r
   r   r   dictfieldsnamehas_default_valuer   )r   descexpected_has_default_by_namefhas_default_by_names        r   testHasDefaultValuesz"GeneratorTest.testHasDefaultValuesl   s    $$//D  #(	$  ++	4FF22 &&!%%	& 	45 	13FG	4s   -A<c                     | j                  t        j                  j                  t        j                  j
                         | j                  t        j                  j                  j                  t        j                  j
                         y r/   )r   r
   optional_int32_extensioncontaining_typeTestAllExtensionsr   TestRequiredsingler   s    r   'testContainingTypeBehaviorForExtensionsz5GeneratorTest.testContainingTypeBehaviorForExtensions|   s`    \::JJ!33>>@\..55EE!33>>@r   c                     | j                  t        j                  j                  d        | j                  t        j                  j
                  j                  t        j                  j                         y r/   )r   r
   rO   extension_scoperR   rS   r   rT   s    r   testExtensionScopez GeneratorTest.testExtensionScope   sR    \::JJ\..55EE!..99;r   c                 F   | j                  t        j                  j                         | j                  t        j                  j
                  j                         t        j                  j                  }|j                  d   }| j                  |j                          y )Na)r7   r
   rO   is_extensionrR   rS   r   r   )r   message_descriptornon_extension_descriptors      r   testIsExtensionzGeneratorTest.testIsExtension   sq    OOL99FFGOOL--44AAB%22==1@@EOO0===>r   c                     t        j                         }| j                  |j                  j	                         j
                         y r/   )r   TestMessageSetr7   r   
GetOptionsmessage_set_wire_formatr*   s     r   testOptionszGeneratorTest.testOptions   s1    )88:EOOE$$//1IIJr   c                     t        j                         }|j                  j                  d   j	                         }| j                  |d u       y )NAnEnum)r   TestMessageWithCustomOptionsr   enum_types_by_namera   r7   )r   r+   enum_optionss      r   testMessageWithCustomOptionsz*GeneratorTest.testMessageWithCustomOptions   s@    'DDFE##66x@KKMLOOL,-r   c                 F   | j                  t        t        j                  j                  j
                        t        t        j                  j                  j                  t        j                  j                  j                  t        j                  j                  j                  g             | j                  t        j                  j                  j
                  g        | j                  t        j                  j                  j                  j
                  g        y r/   )
r   setr
   r   r   nested_typesr   OptionalGroupRepeatedGroupTestEmptyMessagerT   s    r   testNestedTypeszGeneratorTest.testNestedTypes   s    L%%00==>%%33>>%%33>>%%33>>
 	 	\22==JJBO!!//::GGMr   c                    | j                  t        j                  j                  j                  d u        | j                  t        j
                  j                  j                  d u        | j                  t        j
                  j                  j                  j                  t        j
                  j                         | j                  t        j
                  j                  j                  j                  t        j
                  j                         | j                  t        j
                  j                  j                  j                  t        j
                  j                         y r/   )	r7   r
   ro   r   rP   r   r   r   rn   rT   s    r   testContainingTypez GeneratorTest.testContainingType   s    OO%%00@@DHJOO!!,,<<DF!!//::JJ!!,,. 	!!//::JJ!!,,. 	!!//::JJ!!,,.r   c                     | j                  t        j                  j                  d u        | j	                  t        j
                  j                  t        j                  j                         y r/   )r7   r
   _FOREIGNENUMrP   r   _TESTALLTYPES_NESTEDENUMr   r   rT   s    r   "testContainingTypeInEnumDescriptorz0GeneratorTest.testContainingTypeInEnumDescriptor   sJ    OOL--==EF\::JJ!..99;r   c                    | j                  t        j                  j                  j                  j
                  d       t        j                  j                  j                  }| j                  |j                  j
                  d       | j                  t        j                  j                  j                  j
                  d       | j                  t        j                  j                  j
                  d       | j                  t        j                  j                  j
                  d       | j                  t        j                  j                  j
                  d       y )Nprotobuf_unittestprotobuf_unittest_import)r   r
   r   r   filepackager   r   ImportMessagert   ru   _IMPORTENUM)r   rI   s     r   testPackagezGeneratorTest.testPackage   s   !!,,1199 $$22==DTYY&&(;<))4499AA"$ 	!!&&..0CE--22:: 	'',,44"$r   c                 \   | j                  t        j                  j                  j                  g        | j                  t        j
                  j                  j                  dt        fg       | j                  t        j                  j                  j                  dddt        fg       y )Nr!   )*   +   )i/  i  i   )r   r
   r   r   extension_rangesrQ   MAX_EXTENSIONTestMultipleExtensionRangesrT   s    r   testExtensionRangez GeneratorTest.testExtensionRange   s    !!,,==rC&&11BB
]	 	00;;LL	<%!78:r   c                 X   | j                  t        j                  j                  d       | j                  t        j                  j                  d       | j                  t        j                  j                  d u        | j                  t        j                  j                  t        j                  g       | j                  t        j                  j                  t        j                  g       | j                  t        j                  j                  t        j                  g       y )Ngoogle/protobuf/unittest.protorx   )r   r
   r   rG   r{   assertFalseserialized_pbdependenciesr   r   public_dependenciesrT   s    r   testFileDescriptorz GeneratorTest.testFileDescriptor   s    \,,1157\,,446IJ\,,::dBC\,,99)4457(33@@0;;<>(33GG0;;<>r   c                 N   | j                  t        t        d             | j                  t        t        d             | j                  t        t        d             t        t        d      r8| j                  t	        t        j
                  t        j                               y y )NTestMessager'   test_extensionTestService)r7   hasattrr	   r   
issubclassr   r   ServicerT   s    r   testNoGenericServicesz#GeneratorTest.testNoGenericServices   sw    OOG<mLMOOG<eDEOOG<>NOP /?
z"B"N"N")//3 4 @r   c                    t         j                  }| j                  t         j                  |j                  t         j                  j
                            | j                  t         j                  j
                  |j                  v        y r/   )r
   r   r   _TESTALLTYPESmessage_types_by_namerG   r   _TESTALLTYPES_NESTEDMESSAGEr   	file_types     r   testMessageTypesByNamez$GeneratorTest.testMessageTypesByName   sl    ''I""''(B(B(G(GHJ 	0055''	()r   c                     t         j                  }| j                  t         j                  |j                  t         j                  j
                            y r/   )r
   r   r   rt   rg   rG   r   s     r   testEnumTypesByNamez!GeneratorTest.testEnumTypesByName   s?    ''I!!$$\%>%>%C%CDFr   c                     t         j                  }| j                  t         j                  |j                  t         j                  j
                            y r/   )r
   r   r   my_extension_stringextensions_by_namerG   r   s     r   testExtensionsByNamez"GeneratorTest.testExtensionsByName   s?    ''I(($$\%E%E%J%JKMr   c                 6   t        j                         }| j                  d|j                  j                         t        j                         }| j                  d|j                         | j                  t        j                  t
        j                  u        y r4   )	r
   r   r   optional_public_import_messageer   PublicImportMessager7   r   )r   all_type_protopublic_import_protos      r   testPublicImportszGeneratorTest.testPublicImports  sw    !..0NQEEGGH .AACQ+--.OO.BB';;< =r   c                    t        j                         }| j                  |j                  t         j                     d       | j                  |j                  t         j
                     d       | j                  |j                  t         j                     d       | j                  |j                  t         j                     d       y )Nfoobarbazqux)r   TestBadIdentifiersr   
Extensionsr?   
descriptor
reflectionr   )r   r?   s     r   testBadIdentifiersz GeneratorTest.testBadIdentifiers  s    &99;GW''(@(H(HIW''(@(K(KLW''(@(K(KLW''(@(H(HIr   c           	      ^   t         j                  j                  }| j                  dt	        |j
                               | j                  d|j
                  d   j                         | j                  d|j
                  d   j                         | j                  ||j
                  d   j                         | j                  |j
                  d   |j                  d          t        g d      }| j                  |t        |j
                  d   j                  D cg c]  }|j                   c}             |j                  j                         D ]N  \  }}||v r*| j                  |j
                  d   |j                         4| j!                  |j                         P y c c}w )Nr!   oneof_fieldr   )oneof_uint32oneof_nested_messageoneof_stringoneof_bytes)r
   r   r   r   lenoneofsrG   indexassertIsrP   oneofs_by_namerk   rF   r   itemscontaining_oneofassertIsNone)r   rI   nested_namesfieldr   
field_descs         r   	testOneofzGeneratorTest.testOneof  sL   $$//DQDKK()]DKKN$7$78QA,,-MM$A667MM$++a.$"5"5m"DE 7 8LT[[^%:%:;EUZZ;<> #'"5"5";";"= 7
J	|	#dkk!nj&A&AB*556	7 <s    F*c                    | j                  dt        j                  j                  t        j                               | j                  dt        j                  j                  t        j
                               | j                  dt        j                  j                  t        j                               | j                  dt        j                  j                  t        j                               y )NFOO1BAR1)r   r
   TestEnumWithDupValueNamer   FOO2r   BAR2rT   s    r   testEnumWithDupValuez"GeneratorTest.testEnumWithDupValue0  s    V!66;;L<M<MNPV!66;;L<M<MNPV!66;;L<M<MNPV!66;;L<M<MNPr   N)__name__
__module____qualname__r   r,   r@   rM   rU   rX   r^   rc   ri   rp   rr   rv   r~   r   r   r   r   r   r   r   r   r   r   r0   r   r   r   r   :   s~    G7 D2H @;?K.
M.;
$&:
>	4
)FM
=
7$Pr   r   c                   "    e Zd ZdZd Zd Zd Zy)SymbolDatabaseRegistrationTestz?Checks that messages, enums and files are correctly registered.c                    | j                  t        j                  t        j                         j                  d             | j                  t        j                  j                  t        j                         j                  d             | j                  t              5  t        j                         j                  d       d d d        | j                  t        j                  j                  t        j                         j                  d             | j                  t        j                  j                  t        j                         j                  d             y # 1 sw Y   xY w)Nzprotobuf_unittest.TestAllTypesz,protobuf_unittest.TestAllTypes.NestedMessagezprotobuf_unittest.NestedMessagez,protobuf_unittest.TestAllTypes.OptionalGroupz,protobuf_unittest.TestAllTypes.RepeatedGroup)r   r
   r   r   Default	GetSymbolr   assertRaisesKeyErrorrm   rn   rT   s    r   testGetSymbolz,SymbolDatabaseRegistrationTest.testGetSymbol>  s   !!?#:#:#<#F#F,$./ 	!!//!++:	<= 
		8	$ M))*KLM!!//!++:	<= 	!!//!++:	<=M Ms   "$E%%E.c                     | j                  dt        j                         j                  j	                  d      j
                         | j                  dt        j                         j                  j	                  d      j
                         y )Nzprotobuf_unittest.ForeignEnumz)protobuf_unittest.TestAllTypes.NestedEnum)r   r   r   poolFindEnumTypeByName	full_namerT   s    r   r,   z(SymbolDatabaseRegistrationTest.testEnumsQ  sq    '!&&99+	--6Y8 	3!&&997	99BDr   c                     | j                  dt        j                         j                  j	                  d      j
                         y )Nr   )r   r   r   r   FindFileByNamerG   rT   s    r   testFindFileByNamez1SymbolDatabaseRegistrationTest.testFindFileByName[  s8    (!&&55,	..2d4r   N)r   r   r   __doc__r   r,   r   r0   r   r   r   r   ;  s    G=&D4r   r   __main__)r   
__author__unittestgoogle.protobuf.internalr   google.protobufr   r   r   r   r   r	   r
   r   r   r   TestCaser   r   r   mainr0   r   r   <module>r      s|   F
 3
  = 7 / 6 - 9 < ( # +~PH%% ~PB$4X%6%6 $4L z(--/ r   