aboutsummaryrefslogtreecommitdiff
path: root/crosperf/download_images_unittest.py
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2015-12-11 12:07:59 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-14 20:07:20 +0000
commite627fd61c2edba668eb2af8221892286b13f05a3 (patch)
treeee5ccc249db07b031c67fc83d1f4669c509c7720 /crosperf/download_images_unittest.py
parent75e1ccc6513c4529e47007105b7c523755f8e0c0 (diff)
downloadtoolchain-utils-e627fd61c2edba668eb2af8221892286b13f05a3.tar.gz
Crosperf: Finish fixing unittest problems.
This patch finishes fixing the unittest problems. They now all work. BUG=chromium:538397 TEST=./run_tests.sh now completes with no errors. Change-Id: Ie501437d199bfafc8a84cd2a95862550992c2cb8 Reviewed-on: https://chrome-internal-review.googlesource.com/241925 Commit-Ready: Caroline Tice <cmtice@google.com> Tested-by: Caroline Tice <cmtice@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf/download_images_unittest.py')
-rwxr-xr-xcrosperf/download_images_unittest.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/crosperf/download_images_unittest.py b/crosperf/download_images_unittest.py
index 7d6c8c50..9ca40a81 100755
--- a/crosperf/download_images_unittest.py
+++ b/crosperf/download_images_unittest.py
@@ -2,13 +2,15 @@
#
# Copyright 2014 Google Inc. All Rights Reserved
+import os
+import mock
+import unittest
+
import download_images
from cros_utils import command_executer
from cros_utils import logger
-import os
-import mock
-import unittest
+import test_flag
MOCK_LOGGER = logger.GetLogger(log_dir="", mock=True)
@@ -23,13 +25,16 @@ class ImageDownloaderTestcast(unittest.TestCase):
mock_cmd_exec = mock.Mock(spec=command_executer.CommandExecuter)
test_chroot = "/usr/local/home/chromeos"
test_build_id = "lumpy-release/R36-5814.0.0"
+ image_path = ("gs://chromeos-image-archive/%s/chromiumos_test_image.tar.xz"
+ % test_build_id)
downloader = download_images.ImageDownloader(logger_to_use=MOCK_LOGGER,
cmd_exec=mock_cmd_exec)
# Set os.path.exists to always return False and run downloader
mock_path_exists.return_value = False
- downloader._DownloadImage(test_chroot, test_build_id)
+ test_flag.SetTestMode(True)
+ downloader._DownloadImage(test_chroot, test_build_id, image_path)
# Verify os.path.exists was called twice, with proper arguments.
self.assertEqual(mock_path_exists.call_count, 2)
@@ -50,7 +55,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
mock_path_exists.return_value = True
# Run downloader
- downloader._DownloadImage(test_chroot, test_build_id)
+ downloader._DownloadImage(test_chroot, test_build_id,image_path)
# Verify os.path.exists was called twice, with proper arguments.
self.assertEqual(mock_path_exists.call_count, 2)
@@ -118,11 +123,11 @@ class ImageDownloaderTestcast(unittest.TestCase):
self.called_get_build_id = True
return 'lumpy-release/R36-5814.0.0'
- def GoodDownloadImage(root, build_id):
+ def GoodDownloadImage(root, build_id, image_path):
self.called_download_image = True
return "chromiumos_test_image.bin"
- def BadDownloadImage(root, build_id):
+ def BadDownloadImage(root, build_id, image_path):
self.called_download_image = True
return None