def testRecoveryNameNotResolved(self): """Verify error when recovery image url cannot be determined.""" cb_command_lib.HandleSsdExists(self.ssd_name, self.force) 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( (None, None)) _AssertConvertRecoveryError(self)
def testCannotDetermineBaseImageZipUrl(self): """Verify error when name of zip with base image cannot be determined.""" cb_command_lib.HandleSsdExists(self.ssd_name, self.force) 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(None) _AssertConvertRecoveryError(self)
def testBaseImageZipDownloadFails(self): """Verify error when zip containing base image is not downloaded.""" cb_command_lib.HandleSsdExists(self.ssd_name, self.force) 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(False) _AssertConvertRecoveryError(self)
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)
def testSsdImageExistsNoConfirm(self): """Verify error when SSD image exists, user does not confirm overwrite.""" cb_command_lib.HandleSsdExists(self.ssd_name, self.force).AndRaise( cb_constants.BundlingError('')) _AssertConvertRecoveryError(self)
def testGitExistsNotHandled(self): """Verify error when git files exist, user does not confirm overwrite.""" cb_command_lib.HandleSsdExists(self.ssd_name, self.force) cb_command_lib.HandleGitExists(self.force).AndRaise( cb_constants.BundlingError('')) _AssertConvertRecoveryError(self)
def testSsdExistsForceOverwrite(self): """Verify behavior when ssd exists, script options allow overwrite.""" self.force = True os.path.exists(self.ssd_name).AndReturn(True) self.mox.ReplayAll() cb_command_lib.HandleSsdExists(self.ssd_name, self.force)
def testSsdExistsNoForceUserConfirmsOverwrite(self): """Verify behavior when ssd image exists, user confirms overwrite.""" os.path.exists(self.ssd_name).AndReturn(True) cb_command_lib.AskUserConfirmation(mox.IsA(str)).AndReturn(True) self.mox.ReplayAll() cb_command_lib.HandleSsdExists(self.ssd_name, self.force)
def testSsdDoesNotExist(self): """Verify behavior when no ssd image exists.""" os.path.exists(self.ssd_name).AndReturn(False) self.mox.ReplayAll() cb_command_lib.HandleSsdExists(self.ssd_name, self.force)