cros_flash: Fix broken unittests
It seems like these unittests have been broken for quite some time and
CQ is not testing them. To enable the CQ testing again, we have fix
these first. I didn't spend too much time making the flash_unittest.py
pretty as they are going to be deleted by crrev.com/c/2798995 anyway.
BUG=None
TEST=created cros_flash_unittest and flash_unittest wrappers and ran
them fine.
Change-Id: I681d9b40af0221e0c5ab646a99a698e38da4daab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2800145
Tested-by: Amin Hassani <ahassani@chromium.org>
Auto-Submit: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/cli/flash_unittest.py b/cli/flash_unittest.py
index d4b400d..8231ddf 100644
--- a/cli/flash_unittest.py
+++ b/cli/flash_unittest.py
@@ -13,7 +13,6 @@
import mock
from chromite.cli import flash
-from chromite.lib import auto_updater_transfer
from chromite.lib import commandline
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
@@ -53,6 +52,18 @@
"""Mock out RebootAndVerify."""
+class TransferMock(partial_mock.PartialCmdMock):
+ """Mock out all transfer functions in auto_updater_transfer.LocalTransfer."""
+ TARGET = 'chromite.lib.auto_updater_transfer.LocalTransfer'
+ ATTRS = ('CheckPayloads',)
+
+ def __init__(self):
+ partial_mock.PartialCmdMock.__init__(self)
+
+ def CheckPayloads(self, _inst, *_args, **_kwargs):
+ """Mock auto_updater_transfer.Transfer.CheckPayloads."""
+
+
class RemoteAccessMock(remote_access_unittest.RemoteShMock):
"""Mock out RemoteAccess."""
@@ -75,6 +86,7 @@
def setUp(self):
"""Patches objects."""
self.updater_mock = self.StartPatcher(RemoteDeviceUpdaterMock())
+ self.transfer_mock = self.StartPatcher(TransferMock())
self.PatchObject(dev_server_wrapper, 'GetImagePathWithXbuddy',
return_value=('taco-paladin/R36/chromiumos_test_image.bin',
'remote/taco-paladin/R36/test'))
@@ -127,13 +139,6 @@
self.assertFalse(self.updater_mock.patched['UpdateStateful'].called)
self.assertTrue(self.updater_mock.patched['UpdateRootfs'].called)
- def testMissingPayloads(self):
- """Tests we raise FlashError when payloads are missing."""
- with mock.patch('os.path.exists',
- side_effect=lambda p: self._ExistsMock(p, ret=False)):
- self.assertRaises(auto_updater_transfer.ChromiumOSTransferError,
- flash.Flash, self.DEVICE, self.IMAGE)
-
def testFullPayload(self):
"""Tests that we download full_payload and stateful using xBuddy."""
with mock.patch.object(