def testCgptDoesNotExist(self): """Verify behavior when cgpt can be installed fresh.""" cb_command_lib.Download(mox.IsA(str)).AndReturn(True) cb_command_lib.ZipExtract( mox.IsA(str), 'cgpt', path=cb_constants.WORKDIR).AndReturn(True) os.path.exists(mox.IsA(str)).AndReturn(False) cb_command_lib.MoveCgpt(mox.IsA(str), mox.IsA(str)) self.mox.ReplayAll() cb_command_lib.InstallCgpt(self.index_page, self.force)
def testCgptExistsForceOverwrite(self): """Verify behavior when cgpt exists and script input allows overwrite.""" self.force = True cb_command_lib.Download(mox.IsA(str)).AndReturn(True) cb_command_lib.ZipExtract( mox.IsA(str), 'cgpt', path=cb_constants.WORKDIR).AndReturn(True) os.path.exists(mox.IsA(str)).AndReturn(True) cb_command_lib.MoveCgpt(mox.IsA(str), mox.IsA(str)) self.mox.ReplayAll() cb_command_lib.InstallCgpt(self.index_page, self.force)
def testCgptExistsNoForceUserConfirmsOverwrite(self): """Verify behavior when cgpt already exists and user confirms overwrite.""" cb_command_lib.Download(mox.IsA(str)).AndReturn(True) cb_command_lib.ZipExtract( mox.IsA(str), 'cgpt', path=cb_constants.WORKDIR).AndReturn(True) os.path.exists(mox.IsA(str)).AndReturn(True) cb_command_lib.AskUserConfirmation(mox.IsA(str)).AndReturn(True) cb_command_lib.MoveCgpt(mox.IsA(str), mox.IsA(str)) self.mox.ReplayAll() cb_command_lib.InstallCgpt(self.index_page, self.force)
def testInstallCgptFails(self): """Verify error when installing cgpt utility fails.""" cb_command_lib.HandleGitExists(self.force) cb_command_lib.RunCommand(mox.IsA(list)) cb_command_lib.ResolveRecoveryUrl( self.board, self.recovery, alt_naming=0).AndReturn( (self.rec_url, self.index_page)) cb_command_lib.DetermineUrl(self.index_page, mox.IsA(list)).AndReturn( self.zip_url) cb_command_lib.Download(self.zip_url).AndReturn(True) cb_command_lib.HandleSsdExists(self.ssd_name, self.force) cb_command_lib.InstallCgpt(self.index_page, self.force).AndRaise( cb_constants.BundlingError('')) _AssertConvertRecoveryError(self)
def testConvertRecoveryToSsdSuccess(self): """Verify return value when recovery to full ssd conversion succeeds.""" cb_command_lib.HandleGitExists(self.force) cb_command_lib.RunCommand(mox.IsA(list)) cb_command_lib.ResolveRecoveryUrl( self.board, self.recovery, alt_naming=0).AndReturn( (self.rec_url, self.index_page)) cb_command_lib.DetermineUrl(self.index_page, mox.IsA(list)).AndReturn(self.zip_url) cb_command_lib.Download(self.zip_url).AndReturn(True) cb_command_lib.HandleSsdExists(self.ssd_name, self.force) cb_command_lib.InstallCgpt(self.index_page, self.force) cb_command_lib.RunCommand(mox.IsA(list)) self.mox.ReplayAll() actual = cb_command_lib.ConvertRecoveryToSsd(self.image_name, self) self.assertEqual(self.ssd_name, actual)