Remove deprecated service.py usages from test

PiperOrigin-RevId: 668137152
pull/17942/head
Jie Luo 7 months ago committed by Copybara-Service
parent 92f979b721
commit 471ff77270
  1. 7
      python/google/protobuf/internal/generator_test.py
  2. 9
      python/google/protobuf/internal/service_reflection_test.py
  3. 8
      python/google/protobuf/service.py

@ -19,7 +19,6 @@ __author__ = 'robinson@google.com (Will Robinson)'
import unittest import unittest
from google.protobuf.internal import test_bad_identifiers_pb2 from google.protobuf.internal import test_bad_identifiers_pb2
from google.protobuf import service
from google.protobuf import symbol_database from google.protobuf import symbol_database
from google.protobuf import unittest_import_pb2 from google.protobuf import unittest_import_pb2
from google.protobuf import unittest_import_public_pb2 from google.protobuf import unittest_import_public_pb2
@ -283,12 +282,6 @@ class GeneratorTest(unittest.TestCase):
self.assertTrue(hasattr(unittest_no_generic_services_pb2, "FOO")) self.assertTrue(hasattr(unittest_no_generic_services_pb2, "FOO"))
self.assertTrue(hasattr(unittest_no_generic_services_pb2, "test_extension")) self.assertTrue(hasattr(unittest_no_generic_services_pb2, "test_extension"))
# Make sure unittest_no_generic_services_pb2 has no services subclassing
# Proto2 Service class.
if hasattr(unittest_no_generic_services_pb2, "TestService"):
self.assertFalse(issubclass(unittest_no_generic_services_pb2.TestService,
service.Service))
def testMessageTypesByName(self): def testMessageTypesByName(self):
file_type = unittest_pb2.DESCRIPTOR file_type = unittest_pb2.DESCRIPTOR
self.assertEqual( self.assertEqual(

@ -13,21 +13,21 @@ __author__ = 'petar@google.com (Petar Petrov)'
import unittest import unittest
from google.protobuf import service_reflection from google.protobuf import service_reflection
from google.protobuf import service
from google.protobuf import unittest_pb2 from google.protobuf import unittest_pb2
class FooUnitTest(unittest.TestCase): class FooUnitTest(unittest.TestCase):
def testService(self): def testService(self):
class MockRpcChannel(service.RpcChannel):
class MockRpcChannel:
def CallMethod(self, method, controller, request, response, callback): def CallMethod(self, method, controller, request, response, callback):
self.method = method self.method = method
self.controller = controller self.controller = controller
self.request = request self.request = request
callback(response) callback(response)
class MockRpcController(service.RpcController): class MockRpcController:
def SetFailed(self, msg): def SetFailed(self, msg):
self.failure_message = msg self.failure_message = msg
@ -81,7 +81,8 @@ class FooUnitTest(unittest.TestCase):
self.assertEqual(True, srvc.bar_called) self.assertEqual(True, srvc.bar_called)
def testServiceStub(self): def testServiceStub(self):
class MockRpcChannel(service.RpcChannel):
class MockRpcChannel:
def CallMethod(self, method, controller, request, def CallMethod(self, method, controller, request,
response_class, callback): response_class, callback):
self.method = method self.method = method

@ -70,12 +70,12 @@ class Service(object):
Postconditions: Postconditions:
* "done" will be called when the method is complete. This may be * "done" will be called when the method is complete. This may be
before CallMethod() returns or it may be at some point in the future. before CallMethod() returns or it may be at some point in the future.
* If the RPC failed, the response value passed to "done" will be None. * If the RPC failed, the response value passed to "done" will be None.
Further details about the failure can be found by querying the Further details about the failure can be found by querying the
RpcController. RpcController.
""" """
raise NotImplementedError raise NotImplementedError
def GetRequestClass(self, method_descriptor): def GetRequestClass(self, method_descriptor):
"""Returns the class of the request message for the specified method. """Returns the class of the request message for the specified method.

Loading…
Cancel
Save