def testProcessOptionsReuseFlag(self):
    args_with_board = self.DEFAULT_ARGS + ['--board', 'test']
    options = self.parser.parse_args(self.DEFAULT_ARGS)
    options = self.parser.parse_args(args_with_board)
    bisector = cros_bisect.BisectCommand(options)
    bisector.ProcessOptions()
    self.assertFalse(bisector.options.reuse_repo)
    self.assertFalse(bisector.options.reuse_build)
    self.assertFalse(bisector.options.reuse_eval)

    # Flip --reuse.
    options = self.parser.parse_args(args_with_board + ['--reuse'])
    bisector = cros_bisect.BisectCommand(options)
    bisector.ProcessOptions()
    self.assertTrue(bisector.options.reuse_repo)
    self.assertTrue(bisector.options.reuse_build)
    self.assertTrue(bisector.options.reuse_eval)
  def testProcessOptionsResolveBoardFailed(self):
    # No --board specified.
    options = self.parser.parse_args(self.DEFAULT_ARGS)

    self.PatchObject(remote_access, 'ChromiumOSDevice',
                     return_value=cros_test_lib.EasyAttr(board=''))
    bisector = cros_bisect.BisectCommand(options)
    self.assertRaisesRegex(Exception, 'Unable to obtain board name from DUT',
                           bisector.ProcessOptions)
  def testProcessOptionsResolveBoard(self):
    # No --board specified.
    options = self.parser.parse_args(self.DEFAULT_ARGS)

    self.PatchObject(remote_access, 'ChromiumOSDevice',
                     return_value=cros_test_lib.EasyAttr(board='test_board'))
    bisector = cros_bisect.BisectCommand(options)
    bisector.ProcessOptions()
    self.assertEqual('test_board', bisector.options.board)
  def testRun(self):
    options = self.parser.parse_args(self.DEFAULT_ARGS + ['--board', 'test'])

    self.PatchObject(simple_chrome_builder.SimpleChromeBuilder, '__init__',
                     return_value=None)
    self.PatchObject(autotest_evaluator.AutotestEvaluator, '__init__',
                     return_value=None)
    self.PatchObject(git_bisector.GitBisector, '__init__',
                     return_value=None)
    self.PatchObject(git_bisector.GitBisector, 'SetUp')
    self.PatchObject(git_bisector.GitBisector, 'Run')

    bisector = cros_bisect.BisectCommand(options)
    bisector.Run()