Exemplo n.º 1
0
  def testMakeDescriptors(self):
    ds = self.address_book  # DescriptorSet

    descriptors = pyb._MakeDescriptors(
        ds.type_index, ds.descriptor_index, '.tutorial.AddressBook')
    print descriptors

    # Make sure we have all 3
    self.assertEqual(
        set(['.tutorial.AddressBook', 
          '.tutorial.Person',
          '.tutorial.Person.PhoneNumber']),
        set(ds.descriptor_index.keys()))

    print 'DESCRIPTORS'
    pyb.PrintSubtree(ds.descriptor_index)
    print


    print ds.descriptor_index['.tutorial.AddressBook']['person'].fields

    return
    ds = self.descriptor_proto
    descriptors = pyb._MakeDescriptors(
        ds.type_index, ds.descriptor_index, '.proto2.FileDescriptorSet')

    print 'DESCRIPTORS'
    pyb.PrintSubtree(ds.descriptor_index)
    print
Exemplo n.º 2
0
    def testMakeDescriptors(self):
        ds = self.address_book  # DescriptorSet

        descriptors = pyb._MakeDescriptors(ds.type_index, ds.descriptor_index,
                                           '.tutorial.AddressBook')
        print descriptors

        # Make sure we have all 3
        self.assertEqual(
            set([
                '.tutorial.AddressBook', '.tutorial.Person',
                '.tutorial.Person.PhoneNumber'
            ]), set(ds.descriptor_index.keys()))

        print 'DESCRIPTORS'
        pyb.PrintSubtree(ds.descriptor_index)
        print

        print ds.descriptor_index['.tutorial.AddressBook']['person'].fields

        return
        ds = self.descriptor_proto
        descriptors = pyb._MakeDescriptors(ds.type_index, ds.descriptor_index,
                                           '.proto2.FileDescriptorSet')

        print 'DESCRIPTORS'
        pyb.PrintSubtree(ds.descriptor_index)
        print
Exemplo n.º 3
0
  def testDictToTree(self):
    ds = self.address_book  # DescriptorSet
    descriptors = pyb._MakeDescriptors(
        ds.type_index, ds.descriptor_index, '.tutorial.AddressBook')
    t = pyb._DictToTree({'person': [{'name': 'Jill'}]}, descriptors)

    print '---'
    print t
    print '---'
    print 'person'
    print t.value['person']
    print
    print t.descriptors['person']
    print '---'
    print 'person[0]'
    print t.value['person'].value[0]
    print
    print t.value['person'].descriptors
    print '---'
    print "person[0]['name']"
    print t.value['person'].value[0].value['name']
    print
    print t.value['person'].value[0].descriptors

    print t.value['person'].value[0].value['name'].descriptor
Exemplo n.º 4
0
    def testDictToTree(self):
        ds = self.address_book  # DescriptorSet
        descriptors = pyb._MakeDescriptors(ds.type_index, ds.descriptor_index,
                                           '.tutorial.AddressBook')
        t = pyb._DictToTree({'person': [{'name': 'Jill'}]}, descriptors)

        print '---'
        print t
        print '---'
        print 'person'
        print t.value['person']
        print
        print t.descriptors['person']
        print '---'
        print 'person[0]'
        print t.value['person'].value[0]
        print
        print t.value['person'].descriptors
        print '---'
        print "person[0]['name']"
        print t.value['person'].value[0].value['name']
        print
        print t.value['person'].value[0].descriptors

        print t.value['person'].value[0].value['name'].descriptor