ó Du—ac@sâdZdZyddlZWnek r;ddlZnXddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z d ejfd „ƒYZed krÞejƒndS(s*Tests for google.protobuf.message_factory.s"matthewtoia@google.com (Matt Toia)iÿÿÿÿN(tdescriptor_pb2(tapi_implementation(tfactory_test1_pb2(tfactory_test2_pb2(tdescriptor_database(tdescriptor_pool(tmessage_factorytMessageFactoryTestcBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs:tjjtjjƒ|_tjjtjjƒ|_dS(N( RtFileDescriptorProtot FromStringRt DESCRIPTORt serialized_pbtfactory_test1_fdRtfactory_test2_fd(tself((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pytsetUp4s  cCsÇ|ƒ}d|_d|_d|j_d|j_d|j_d|jj_d|j_|jj j dddgƒ|jj j d ƒd|_d|_d|j_d|j _d |j j _d |j _d |_|j j d ddgƒ|j j dƒ|j jƒd |j d_d|j d_|j jddddƒd |jj_d|jjjj_|jƒ}tjj|ƒ}|jƒ}|j||ƒ|j|ƒ}|j||ƒdS(Ni*isnested message valueiiuoneutwouthreeufourisone deeps zero deepthellotworldtpart_1ttestingtpart_2t123i(t mandatorytnested_factory_2_enumtnested_factory_2_messagetvaluetfactory_1_messagetfactory_1_enumtnested_factory_1_enumtnested_factory_1_messaget scalar_valuet list_valuetextendtappendtcircular_messagetgroupedtaddRRtlooptSerializeToStringRtFactory2MessageR t assertEqual(Rtclstmsgt serializedt convertedt reserializedtresult((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyt_ExerciseDynamicClass:s>                cCs±tjƒ}tj|ƒ}|j|jƒ|j|jƒtjƒ}|j |j dƒƒ}|j |t j kƒ|j|ƒ|j |j dƒƒ}|j||kƒdS(Ns/google.protobuf.python.internal.Factory2Message(RtDescriptorDatabaseRtDescriptorPooltAddR R RtMessageFactoryt GetPrototypetFindMessageTypeByNamet assertFalseRR'R/t assertTrue(RtdbtpooltfactoryR)tcls2((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyttestGetPrototype\s       cCsxtdƒD]}|j|jj|jjƒtj|j|jgƒ}|jt ddgƒj t |j ƒƒƒƒ|j |dƒ|d}|jt ddgƒj t d„|j jjj|j ƒDƒƒƒƒ|dƒ}|jjdƒ}|jjdƒ}d|j|google.protobuf.python.internal.Factory2Message.one_more_fields-google.protobuf.python.internal.another_fieldcss|]}|jVqdS(N(t full_name(t.0text((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pys ‚sttest1ttest2i!0tcppit(trangetassertInR tnameR t dependencyRt GetMessagesR7tsettissubsettkeysR/R tfileR9tFindAllExtensionst Extensionst_FindExtensionByNameR(tNonet_FindExtensionByNumberRtTypetlent assertRaisest TypeError(Rt_tmessagest factory_msg1tmsg1text1text2((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyttestGetMessagesjsN              "    c CsDtjƒ}tjd|ƒ}tjƒ}d|_d|_|jj ƒ}d|_|j j ƒ}d|_ d|_ |j |ƒ|j|jgƒ}|jd|ƒtjƒ}d|_d|_|jjdƒ|jj ƒ}d |_|jj ƒ}d |_d |_tjj|_d |_d|_|j |ƒ|j|jgƒ}|jd |ƒtjƒ}d |_d|_|jjdƒ|jj ƒ}d|_|jj ƒ}d |_d |_tjj|_d|_d|_|j |ƒ|jtƒ}|j|jgƒWdQX|jt|jƒddgƒdS(NR9s(google/protobuf/internal/container.protosgoogle.protobuf.python.internalt Containerii s)google.protobuf.python.internal.Containers(google/protobuf/internal/extension.protot Extensiontextension_fieldis)google.protobuf.python.internal.Extensions(google/protobuf/internal/duplicate.protot DuplicatesçExtensions "google.protobuf.python.internal.Duplicate.extension_field" and "google.protobuf.python.internal.Extension.extension_field" both try to extend message type "google.protobuf.python.internal.Container" with field number 2.s!Double registration of Extensions(RR1RR3RRRFtpackaget message_typeR$textension_rangetstarttendR2RHRERGR!t extensiontnumbertFieldDescriptorPrototLABEL_OPTIONALtlabelt type_nametextendeeRTt Exceptiontstrt exception( RR9R:tfR*trngtmsgsR?tcm((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyttestDuplicateExtensionNumberžs\                          (t__name__t __module__RR/R<R\Rt(((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyR2s   "  4t__main__(t__doc__t __author__t unittest2tunittestt ImportErrortgoogle.protobufRtgoogle.protobuf.internalRRRRRRtTestCaseRRutmain(((sQ/usr/lib/python2.7/site-packages/google/protobuf/internal/message_factory_test.pyt s ª