Exemple #1
0
    def testDefinitionName(self):
        """Test getting service definition name."""
        class TheService(remote.Service):
            pass

        module_name = test_util.get_module_name(ServiceTest)
        self.assertEqual(TheService.definition_name(),
                         '%s.TheService' % module_name)
        self.assertTrue(TheService.outer_definition_name(), module_name)
        self.assertTrue(TheService.definition_package(), module_name)
  def CheckServiceMappings(self, mappings):
    module_name = test_util.get_module_name(RegistryServiceTest)
    service1_mapping = registry.ServiceMapping()
    service1_mapping.name = 'my-service1'
    service1_mapping.definition = '%s.MyService1' % module_name

    service2_mapping = registry.ServiceMapping()
    service2_mapping.name = 'my-service2'
    service2_mapping.definition = '%s.MyService2' % module_name

    self.assertIterEqual(mappings, [service1_mapping, service2_mapping])
Exemple #3
0
  def CheckServiceMappings(self, mappings):
    module_name = test_util.get_module_name(RegistryServiceTest)
    service1_mapping = registry.ServiceMapping()
    service1_mapping.name = 'my-service1'
    service1_mapping.definition = '%s.MyService1' % module_name

    service2_mapping = registry.ServiceMapping()
    service2_mapping.name = 'my-service2'
    service2_mapping.definition = '%s.MyService2' % module_name

    self.assertIterEqual(mappings, [service1_mapping, service2_mapping])
  def testDefinitionName(self):
    """Test getting service definition name."""
    class TheService(remote.Service):
      pass

    module_name = test_util.get_module_name(ServiceTest)
    self.assertEqual(TheService.definition_name(),
                     '%s.TheService' % module_name)
    self.assertTrue(TheService.outer_definition_name(),
                    module_name)
    self.assertTrue(TheService.definition_package(),
                    module_name)
Exemple #5
0
    def CheckServiceMappings(self, mappings):
        module_name = test_util.get_module_name(RegistryServiceTest)
        service1_mapping = registry.ServiceMapping()
        service1_mapping.name = 'my-service1'
        service1_mapping.definition = '%s.MyService1' % module_name

        service2_mapping = registry.ServiceMapping()
        service2_mapping.name = 'my-service2'
        service2_mapping.definition = '%s.MyService2' % module_name

        mappings.sort(key=lambda mapping: mapping.name)

        self.assertEquals(mappings[0], service1_mapping)
        self.assertEquals(mappings[1], service2_mapping)
  def CheckServiceMappings(self, mappings):
    module_name = test_util.get_module_name(RegistryServiceTest)
    service1_mapping = registry.ServiceMapping()
    service1_mapping.name = 'my-service1'
    service1_mapping.definition = '%s.MyService1' % module_name

    service2_mapping = registry.ServiceMapping()
    service2_mapping.name = 'my-service2'
    service2_mapping.definition = '%s.MyService2' % module_name

    mappings.sort(key=lambda mapping: mapping.name)

    self.assertEquals(mappings[0], service1_mapping)
    self.assertEquals(mappings[1], service2_mapping)
  def testDefault_EnumField(self):
    class MyEnum(messages.Enum):

      VAL = 1

    module_name = test_util.get_module_name(MyEnum)
    field = messages.EnumField(MyEnum, 10, default=MyEnum.VAL)
    field.name = 'a_field'

    expected = descriptor.FieldDescriptor()
    expected.name = 'a_field'
    expected.number = 10
    expected.label = descriptor.FieldDescriptor.Label.OPTIONAL
    expected.variant = messages.EnumField.DEFAULT_VARIANT
    expected.type_name = '%s.MyEnum' % module_name
    expected.default_value = '1'

    described = descriptor.describe_field(field)
    self.assertEquals(expected, described)
    def testDefault_EnumField(self):
        class MyEnum(messages.Enum):

            VAL = 1

        module_name = test_util.get_module_name(MyEnum)
        field = messages.EnumField(MyEnum, 10, default=MyEnum.VAL)
        field.name = 'a_field'

        expected = descriptor.FieldDescriptor()
        expected.name = 'a_field'
        expected.number = 10
        expected.label = descriptor.FieldDescriptor.Label.OPTIONAL
        expected.variant = messages.EnumField.DEFAULT_VARIANT
        expected.type_name = '%s.MyEnum' % module_name
        expected.default_value = '1'

        described = descriptor.describe_field(field)
        self.assertEquals(expected, described)
  def testDescribe(self):
    class Request(messages.Message):
      pass

    class Response(messages.Message):
      pass

    @remote.method(Request, Response)
    def remote_method(request):
      pass

    module_name = test_util.get_module_name(DescribeMethodTest)
    expected = descriptor.MethodDescriptor()
    expected.name = 'remote_method'
    expected.request_type = '%s.Request' % module_name
    expected.response_type = '%s.Response' % module_name

    described = descriptor.describe_method(remote_method)
    described.check_initialized()
    self.assertEquals(expected, described)
    def testDescribe(self):
        class Request(messages.Message):
            pass

        class Response(messages.Message):
            pass

        @remote.method(Request, Response)
        def remote_method(request):
            pass

        module_name = test_util.get_module_name(DescribeMethodTest)
        expected = descriptor.MethodDescriptor()
        expected.name = 'remote_method'
        expected.request_type = '%s.Request' % module_name
        expected.response_type = '%s.Response' % module_name

        described = descriptor.describe_method(remote_method)
        described.check_initialized()
        self.assertEquals(expected, described)