def testMarkdownGenerators(self):
        """CommandMarkdownGenerator and CliTreeMarkdownGenerator should match."""

        # The normal help doc generation flow: generate the markdown for the loaded
        # CLI into a directory, one markdown file per command.
        command_directory = os.path.join(self.temp_path, 'command')
        walker_util.DocumentGenerator(self.cli, command_directory, 'markdown',
                                      '.md').Walk()

        # The help doc generation flow under test: generate the markdown for the
        # generated cli_tree into a directory, one markdown file per command using
        # the same markdown file name scheme as above.
        tree_directory = os.path.join(self.temp_path, 'tree')
        files.MakeDir(tree_directory)
        internal_tree = walker_util.GCloudTreeGenerator(self.cli).Walk()
        external_tree = io.StringIO()
        resource_printer.Print(resources=internal_tree,
                               print_format='json',
                               out=external_tree)
        tree = json.loads(external_tree.getvalue())
        GenerateMarkdownFromCliTree(tree, tree, tree_directory)

        # Compare the output dir contents.
        accumulator = Accumulator()
        help_util.DirDiff(command_directory, tree_directory, accumulator)
        self.assertEqual(0, accumulator.GetChanges())
Esempio n. 2
0
 def Run(self, args):
   return walker_util.GCloudTreeGenerator(self.cli).Walk(args.hidden,
                                                         args.restrict)
Esempio n. 3
0
 def testGCloudTreeGenerator(self):
   """Test the gcloud command and group tree list."""
   result = walker_util.GCloudTreeGenerator(self.cli).Walk()
   resource_printer.Print(resources=result, print_format='json')
   self.AssertOutputIsGolden(__file__, 'walker_util', 'gcloud.tree')
Esempio n. 4
0
 def Run(self, args):
     return walker_util.GCloudTreeGenerator(
         self._cli_power_users_only).Walk(args.hidden, args.restrict)