def testNoPackageName(self):
        """Test describing a module with no module name."""
        module = types.ModuleType('')

        expected = descriptor.FileDescriptor()

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testNoPackageName(self):
        """Test describing a module with no module name."""
        module = types.ModuleType('')

        expected = descriptor.FileDescriptor()

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testEmptyModule(self):
        """Test describing an empty file."""
        module = types.ModuleType('my.package.name')

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package.name'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testEmptyModule(self):
        """Test describing an empty file."""
        module = types.ModuleType('my.package.name')

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package.name'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testMain(self):
        """Test using the 'package' module attribute."""
        module = types.ModuleType('__main__')
        module.__file__ = '/blim/blam/bloom/my_package.py'

        expected = descriptor.FileDescriptor()
        expected.package = 'my_package'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testPackageName(self):
        """Test using the 'package' module attribute."""
        module = types.ModuleType('my.module.name')
        module.package = 'my.package.name'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package.name'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testMain(self):
        """Test using the 'package' module attribute."""
        module = types.ModuleType('__main__')
        module.__file__ = '/blim/blam/bloom/my_package.py'

        expected = descriptor.FileDescriptor()
        expected.package = 'my_package'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testPackageName(self):
        """Test using the 'package' module attribute."""
        module = types.ModuleType('my.module.name')
        module.package = 'my.package.name'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package.name'

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testEnums(self):
        """Test that enums are described."""
        module = self.LoadModule(
            'my.package', 'class Enum1(messages.Enum): pass\n'
            'class Enum2(messages.Enum): pass\n')

        enum1 = descriptor.EnumDescriptor()
        enum1.name = 'Enum1'

        enum2 = descriptor.EnumDescriptor()
        enum2.name = 'Enum2'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package'
        expected.enum_types = [enum1, enum2]

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testMessages(self):
        """Test that messages are described."""
        module = self.LoadModule(
            'my.package', 'class Message1(messages.Message): pass\n'
            'class Message2(messages.Message): pass\n')

        message1 = descriptor.MessageDescriptor()
        message1.name = 'Message1'

        message2 = descriptor.MessageDescriptor()
        message2.name = 'Message2'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package'
        expected.message_types = [message1, message2]

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testEnums(self):
        """Test that enums are described."""
        module = self.LoadModule('my.package',
                                 'class Enum1(messages.Enum): pass\n'
                                 'class Enum2(messages.Enum): pass\n')

        enum1 = descriptor.EnumDescriptor()
        enum1.name = 'Enum1'

        enum2 = descriptor.EnumDescriptor()
        enum2.name = 'Enum2'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package'
        expected.enum_types = [enum1, enum2]

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
    def testMessages(self):
        """Test that messages are described."""
        module = self.LoadModule('my.package',
                                 'class Message1(messages.Message): pass\n'
                                 'class Message2(messages.Message): pass\n')

        message1 = descriptor.MessageDescriptor()
        message1.name = 'Message1'

        message2 = descriptor.MessageDescriptor()
        message2.name = 'Message2'

        expected = descriptor.FileDescriptor()
        expected.package = 'my.package'
        expected.message_types = [message1, message2]

        described = descriptor.describe_file(module)
        described.check_initialized()
        self.assertEquals(expected, described)
 def testModule(self):
     self.assertEquals(descriptor.describe_file(test_util),
                       descriptor.describe(test_util))
 def testModule(self):
     self.assertEquals(descriptor.describe_file(test_util),
                       descriptor.describe(test_util))