def testConvertDottedKeysToNested(self):
        docs = {
            'doc1.sub2': {
                'name': 'doc1.sub2'
            },
            'doc1': {
                'name': 'doc1'
            },
            'doc2': {
                'name': 'doc2'
            },
            'doc1.sub1.subsub1': {
                'name': 'doc1.sub1.subsub1'
            },
            'doc1.sub1': {
                'name': 'doc1.sub1'
            }
        }

        expected_docs = {
            'doc1': {
                'name': 'doc1',
                'children': {
                    'sub1': {
                        'name': 'sub1',
                        'children': {
                            'subsub1': {
                                'name': 'subsub1'
                            }
                        }
                    },
                    'sub2': {
                        'name': 'sub2'
                    }
                }
            },
            'doc2': {
                'name': 'doc2'
            }
        }

        self.assertEqual(expected_docs, ConvertDottedKeysToNested(docs))
 def for_templates(manifest_features, platform):
     return _AddLevelAnnotations(
         _ListifyAndSortDocs(ConvertDottedKeysToNested(
             features_utility.Filtered(manifest_features,
                                       platform + 's')),
                             app_name=platform.capitalize()))
Пример #3
0
 def resolve():
     manifest_features = future_manifest_features.Get()
     return _AddLevelAnnotations(
         _ListifyAndSortDocs(
             ConvertDottedKeysToNested(deepcopy(manifest_features)),
             app_name=PluralToSingular(platform).capitalize()))