def testLoadCommands(self):
    """Tests import commands correctly."""
    self.mox.StubOutWithMock(commands, '_FindModules')
    self.mox.StubOutWithMock(imp, 'load_module')
    self.mox.StubOutWithMock(imp, 'find_module')
    fake_command_file = 'cros_command_test.py'
    fake_module = 'cros_command_test'
    module_tuple = 'file', 'pathname', 'description'
    commands._FindModules(mox.IgnoreArg()).AndReturn([fake_command_file])
    imp.find_module(fake_module, mox.IgnoreArg()).AndReturn(module_tuple)
    imp.load_module(fake_module, *module_tuple)

    self.mox.ReplayAll()
    commands._ImportCommands()
    self.mox.VerifyAll()
Example #2
0
    def testLoadCommands(self):
        """Tests import commands correctly."""
        self.mox.StubOutWithMock(commands, "_FindModules")
        self.mox.StubOutWithMock(imp, "load_module")
        self.mox.StubOutWithMock(imp, "find_module")
        fake_command_file = "cros_command_test.py"
        fake_module = "cros_command_test"
        module_tuple = "file", "pathname", "description"
        commands._FindModules(mox.IgnoreArg()).AndReturn([fake_command_file])
        imp.find_module(fake_module, mox.IgnoreArg()).AndReturn(module_tuple)
        imp.load_module(fake_module, *module_tuple)

        self.mox.ReplayAll()
        commands._ImportCommands()
        self.mox.VerifyAll()
Example #3
0
    def testLoadCommands(self):
        """Tests import commands correctly."""
        self.mox.StubOutWithMock(commands, '_FindModules')
        self.mox.StubOutWithMock(imp, 'load_module')
        self.mox.StubOutWithMock(imp, 'find_module')
        fake_command_file = 'cros_command_test.py'
        fake_module = 'cros_command_test'
        module_tuple = 'file', 'pathname', 'description'
        commands._FindModules(mox.IgnoreArg()).AndReturn([fake_command_file])
        imp.find_module(fake_module, mox.IgnoreArg()).AndReturn(module_tuple)
        imp.load_module(fake_module, *module_tuple)

        self.mox.ReplayAll()
        commands._ImportCommands()
        self.mox.VerifyAll()
Example #4
0
    def testFindModules(self):
        """Tests that we can return modules correctly when mocking out glob."""
        self.mox.StubOutWithMock(glob, "glob")
        fake_command_file = "cros_command_test.py"
        filtered_file = "cros_command_unittest.py"
        mydir = "mydir"

        glob.glob(mox.StrContains(mydir)).AndReturn([fake_command_file, filtered_file])

        self.mox.ReplayAll()
        self.assertEqual(commands._FindModules(mydir), [fake_command_file])
        self.mox.VerifyAll()
Example #5
0
    def testFindModules(self):
        """Tests that we can return modules correctly when mocking out glob."""
        self.mox.StubOutWithMock(glob, 'glob')
        fake_command_file = 'cros_command_test.py'
        filtered_file = 'cros_command_unittest.py'
        mydir = 'mydir'

        glob.glob(mox.StrContains(mydir)).AndReturn(
            [fake_command_file, filtered_file])

        self.mox.ReplayAll()
        self.assertEqual(commands._FindModules(mydir), [fake_command_file])
        self.mox.VerifyAll()