~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_help.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-16 09:33:16 UTC
  • mfrom: (6059.3.6 747050-config-help)
  • Revision ID: pqm@pqm.ubuntu.com-20110816093316-favbhalxcbqwxhuw
(vila) Implement per-config option help (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib import (
22
22
    builtins,
23
23
    commands,
 
24
    config,
24
25
    errors,
25
26
    help,
26
27
    help_topics,
561
562
        self.assertEqual('', index.prefix)
562
563
 
563
564
 
 
565
class TestConfigOptionIndex(TestHelp):
 
566
    """Tests for the HelpCommandIndex class."""
 
567
 
 
568
    def setUp(self):
 
569
        super(TestConfigOptionIndex, self).setUp()
 
570
        self.index = help_topics.ConfigOptionHelpIndex()
 
571
 
 
572
    def test_get_topics_None(self):
 
573
        """Searching for None returns an empty list."""
 
574
        self.assertEqual([], self.index.get_topics(None))
 
575
 
 
576
    def test_get_topics_no_topic(self):
 
577
        self.assertEqual([], self.index.get_topics('nothing by this name'))
 
578
 
 
579
    def test_prefix(self):
 
580
        self.assertEqual('configuration/', self.index.prefix)
 
581
 
 
582
    def test_get_topic_with_prefix(self):
 
583
        topics = self.index.get_topics('configuration/default_format')
 
584
        self.assertLength(1, topics)
 
585
        opt = topics[0]
 
586
        self.assertIsInstance(opt, config.Option)
 
587
        self.assertEquals('default_format', opt.name)
 
588
 
 
589
 
564
590
class TestCommandIndex(TestHelp):
565
591
    """Tests for the HelpCommandIndex class."""
566
592
 
603
629
    def test_default_search_path(self):
604
630
        """The default search path should include internal indexs."""
605
631
        indices = help.HelpIndices()
606
 
        self.assertEqual(3, len(indices.search_path))
 
632
        self.assertEqual(4, len(indices.search_path))
607
633
        # help topics should be searched in first.
608
634
        self.assertIsInstance(indices.search_path[0],
609
 
            help_topics.HelpTopicIndex)
 
635
                              help_topics.HelpTopicIndex)
610
636
        # with commands being search second.
611
637
        self.assertIsInstance(indices.search_path[1],
612
 
            commands.HelpCommandIndex)
613
 
        # and plugins are a third index.
 
638
                              commands.HelpCommandIndex)
 
639
        # plugins are a third index.
614
640
        self.assertIsInstance(indices.search_path[2],
615
 
            plugin.PluginsHelpIndex)
 
641
                              plugin.PluginsHelpIndex)
 
642
        # config options are a fourth index
 
643
        self.assertIsInstance(indices.search_path[3],
 
644
                              help_topics.ConfigOptionHelpIndex)
616
645
 
617
646
    def test_search_for_unknown_topic_raises(self):
618
647
        """Searching for an unknown topic should raise NoHelpTopic."""