pushimage_unittests: add testcase for empty sign_types
When pushimage is run as a binary, the default value for |sign_types| as
passed to PushImage() is None. When pushimage.py is used as a library,
for example from commands.py, |sign_types| is always a list or tuple.
This patch adds a test case to check behavior of PushImage() when
|sign_types| is empty.
BUG=chromium:527277
BUG=chromium:512940
TEST=Unittests
Change-Id: Ib05ec7a8c937d921b01358f5891fc45e846a1cf1
Reviewed-on: https://chromium-review.googlesource.com/297304
Commit-Ready: Amey Deshpande <ameyd@google.com>
Tested-by: Amey Deshpande <ameyd@google.com>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/pushimage_unittest.py b/scripts/pushimage_unittest.py
index 1dd7c4a..5edbd53 100644
--- a/scripts/pushimage_unittest.py
+++ b/scripts/pushimage_unittest.py
@@ -168,6 +168,26 @@
self.assertEqual(urls, EXPECTED)
+ def testBasic_SignTypesEmptyList(self):
+ """Tests PushImage behavior when |sign_types| is empty instead of None.
+
+ As part of the buildbots, PushImage function always receives a tuple for
+ |sign_types| argument. This test checks the behavior for empty tuple.
+ """
+ EXPECTED = {
+ 'canary': [
+ ('gs://chromeos-releases/canary-channel/test.board-hi/5126.0.0/'
+ 'ChromeOS-recovery-R34-5126.0.0-test.board-hi.instructions')],
+ 'dev': [
+ ('gs://chromeos-releases/dev-channel/test.board-hi/5126.0.0/'
+ 'ChromeOS-recovery-R34-5126.0.0-test.board-hi.instructions')],
+ }
+ with mock.patch.object(gs.GSContext, 'Exists', return_value=True):
+ urls = pushimage.PushImage('/src', 'test.board', 'R34-5126.0.0',
+ profile='hi', sign_types=())
+
+ self.assertEqual(urls, EXPECTED)
+
def testBasicMock(self):
"""Simple smoke test in mock mode"""
with mock.patch.object(gs.GSContext, 'Exists', return_value=True):