Ejemplo n.º 1
0
class TestAboutMethods(unittest.TestCase):
    """
    Unit tests for the About core plugin.
    """
    def setUp(self):
        self.sbtools = SBTools()
        self.about = About(self.sbtools)

    def test001_init(self):
        self.assertEqual(self.about.sbtools, self.sbtools)

    def test002_init_parser(self):
        self.assertEqual(self.about.parser.get_usage().strip(), "Usage: about [subcommand]")
        self.assertEqual(self.about.parser.get_description(), "about: Provide 'about' information on the SBTools core package or a plugin when a subcommand is provided.")

    def test003_get_command(self):
        self.assertEqual(self.about.get_command(), "about")

    def test004_get_alt_commands(self):
        self.assertEqual(self.about.get_alt_commands(), [])

    def test005_get_full_command_str(self):
        self.assertEqual(self.about.get_full_command_str(), "about")

    def test006_get_about(self):
        self.assertEqual(self.about.get_about(), "The About tool is a core component of the SBTools package.")

    def test007_run_unknown_subcommand(self):
        argv_saved = sys.argv
        sys.argv = ['sbtools', 'about', 'unknown-sc']

        # Make sure the expected exception is raised.
        self.assertRaises(sbtools.UnknownSubcommandError, self.about.run)

        # Make sure the expected message is included with the
        # exception.
        try:
            self.about.run()
        except sbtools.UnknownSubcommandError, msg:
            self.assertEqual(str(msg), "unknown-sc")

        sys.argv = argv_saved
Ejemplo n.º 2
0
 def setUp(self):
     self.sbtools = SBTools()
     self.about = About(self.sbtools)