Exemplo n.º 1
0
 def testGetSummaryWithCommandGroup(self):
   # With just a list of positional arguments.
   results_map = {'': lookup.CAPSULE, 'long': lookup.COMMANDS}
   expected_summary = (
       'gcloud sdk tests second level group.\n'
       '# COMMANDS\n'
       'hidden-command, hiddengroup, LONG-help, second-level-command-1, '
       'second-level-command-b, subgroup, xyzzy'
   )
   # Mimic the first step of replacing 'commands' dict with list of keys.
   sdk_node = copy.deepcopy(self.sdk)
   sdk_node.update(
       {lookup.COMMANDS:
        list(self.sdk.get(lookup.COMMANDS, {}).keys())})
   self.assertEqual(expected_summary,
                    search_util.GetSummary(sdk_node, results_map))
   # Should still work if the commands dict wasn't changed for some reason.
   self.assertEqual(expected_summary,
                    search_util.GetSummary(self.sdk, results_map))
Exemplo n.º 2
0
 def testGetSummaryWithNonStringSections(self):
   found_terms = {
       'dict': 'dictsection',
       'number': 'numbersection'}
   expected_summary = ('Brief description of what Nothing Happens means.\n'
                       '# DICTSECTION\n'
                       'a, b\n'
                       '# NUMBERSECTION\n'
                       '12345')
   # Test that sections that contain non strings are handled.
   xyzzy = copy.deepcopy(self.xyzzy)
   xyzzy.update({'dictsection': {'a': 1, 'b': 2},
                 'numbersection': 12345})
   self.assertEqual(expected_summary,
                    search_util.GetSummary(xyzzy, found_terms))
Exemplo n.º 3
0
 def testGetSummaryWithInvalidSections(self, location, expected_expression):
   with self.assertRaisesRegex(AssertionError, expected_expression):
     search_util.GetSummary(self.xyzzy, {'term': location})
Exemplo n.º 4
0
 def testGetSummaryWithSection(self, results_map, expected_summary):
   self.assertEqual(expected_summary,
                    search_util.GetSummary(self.long_help, results_map))
Exemplo n.º 5
0
 def testGetSummaryWithArgument(self, results_map, expected_summary):
   self.assertEqual(expected_summary,
                    search_util.GetSummary(self.xyzzy, results_map))
Exemplo n.º 6
0
 def testGetSummaryJustCapsule(self, results_map, summary_kwargs,
                               expected_summary):
   self.assertEqual(expected_summary,
                    search_util.GetSummary(self.long_help, results_map,
                                           **summary_kwargs))