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

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

    def test002_init_parser(self):
        self.assertEqual(self.file.parser.get_usage().strip(), "Usage: file SUBCOMMAND")
        self.assertEqual(self.file.parser.get_description(), "file: Print the path and filename of the specified subcommand's plugin.")

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

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

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

    def test005_get_about(self):
        self.assertEqual(self.file.get_about(), "The File tool is a core component of the SBTools package.")

    def test006_run_missing_subcommand(self):
        saved_argv = sys.argv
        sys.argv = ['sbtools', 'file']
        # Make sure the expected exception is thrown.
        self.assertRaises(SBToolError, self.file.run)

        # Make sure the expected message is attached to the exception.
        try:
            self.file.run()
        except SBToolError, msg:
            self.assertEqual(str(msg), "Missing subcommand argument.\nType 'sbtools help file' for usage.")

        sys.argv = saved_argv
Ejemplo n.º 2
0
 def setUp(self):
     self.sbtools = SBTools()
     self.file = File(self.sbtools)