ó
X¾÷Xc           @   s¢   d  Z  d Z y d d l Z Wn e k
 r; d d l Z n Xd d l m Z d d l m Z d d l m Z d e j	 f d „  ƒ  YZ
 e d	 k rž e j ƒ  n  d S(
   s6   Tests for google.protobuf.internal.service_reflection.s   petar@google.com (Petar Petrov)iÿÿÿÿN(   t   unittest_pb2(   t   service_reflection(   t   servicet   FooUnitTestc           B   s   e  Z d  „  Z d „  Z RS(   c   
         sç  d t  j f d „  ƒ  Y} d t  j f d „  ƒ  Y} d  ˆ  _ d t j f d „  ƒ  Y} d  ˆ  _ ‡  f d †  } | ƒ  } | ƒ  } | ƒ  } | j | t j ƒ  | ƒ ˆ  j	 d | j
 ƒ ˆ  j	 d  ˆ  j ƒ d  | _
 t j j ƒ  } | j | j d	 | t j ƒ  | ƒ ˆ  j	 d
 | j
 ƒ ˆ  j	 d  ˆ  j ƒ d t j f d „  ƒ  Y}	 |	 ƒ  } d  | _
 | j | t j ƒ  | ƒ ˆ  j	 d  | j
 ƒ ˆ  j	 t | j ƒ d  | _
 | j | j d	 | t j ƒ  | ƒ ˆ  j	 d  | j
 ƒ ˆ  j	 t | j ƒ d  S(   Nt   MockRpcChannelc           B   s   e  Z d  „  Z RS(   c         S   s)   | |  _  | |  _ | |  _ | | ƒ d  S(   N(   t   methodt
   controllert   request(   t   selfR   R   R   t   responset   callback(    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt
   CallMethod4   s    			(   t   __name__t
   __module__R   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   3   s   t   MockRpcControllerc           B   s   e  Z d  „  Z RS(   c         S   s   | |  _  d  S(   N(   t   failure_message(   R   t   msg(    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt	   SetFailed;   s    (   R   R   R   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   :   s   t	   MyServicec           B   s   e  Z RS(    (   R   R   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   @   s   c            s   |  ˆ  _  d  S(   N(   t   callback_response(   R	   (   R   (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt
   MyCallbackE   s    s   Method Foo not implemented.i   s   Method Bar not implemented.t   MyServiceImplc           B   s   e  Z d  „  Z d „  Z RS(   c         S   s   t  |  _ d  S(   N(   t   Truet
   foo_called(   R   t   rpc_controllerR   t   done(    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt   FooZ   s    c         S   s   t  |  _ d  S(   N(   R   t
   bar_called(   R   R   R   R   (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt   Bar\   s    (   R   R   R   R   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   Y   s   	(   R   t
   RpcChannelt   RpcControllert   NoneR   R    t   TestServiceR   t
   FooRequestt   assertEqualR   t   GetDescriptorR   t   methodst
   BarRequestR   R   R   (
   R   R   R   R   R   R   t   channelt   srvct   service_descriptorR   (    (   R   sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt   testService2   s>    						
		
			c            sç   d t  j f d „  ƒ  Y} d  ˆ  _ ‡  f d †  } | ƒ  } t j | ƒ } d } d } ˆ  j t j j ƒ  | j ƒ  ƒ | j | | | ƒ ˆ  j	 ˆ  j t j
 ƒ ˆ  j | | j ƒ ˆ  j | | j ƒ ˆ  j | j ƒ  j d | j ƒ d  S(   NR   c           B   s   e  Z d  „  Z RS(   c         S   s,   | |  _  | |  _ | |  _ | | ƒ  ƒ d  S(   N(   R   R   R   (   R   R   R   R   t   response_classR
   (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   m   s    			(   R   R   R   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   l   s   c            s   |  ˆ  _  d  S(   N(   R   (   R	   (   R   (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   v   s    R   R   i    (   R   R   R   R   R    t   TestService_StubR"   R#   R   t   assertIsInstancet   FooResponseR   R   R$   R   (   R   R   R   R&   t   stubR   R   (    (   R   sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt   testServiceStubk   s    		(   R   R   R)   R/   (    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyR   0   s   	9t   __main__(   t   __doc__t
   __author__t	   unittest2t   unittestt   ImportErrort   google.protobufR    R   R   t   TestCaseR   R   t   main(    (    (    sR   /tmp/pip-build-h1VYrz/protobuf/google/protobuf/internal/service_reflection_test.pyt   <module>!   s   [