aboutsummaryrefslogtreecommitdiff
path: root/crosperf/download_images_unittest.py
diff options
context:
space:
mode:
authorYunlian Jiang <yunlian@chromium.org>2015-12-21 10:51:03 -0800
committerYunlian Jiang <yunlian@google.com>2015-12-21 19:30:53 +0000
commit944674b1e3c67d53b802337ae4bc7d11c269f652 (patch)
tree1799017615b0b229d5bf859f5944bb65a8169365 /crosperf/download_images_unittest.py
parent76cdacea0fef665b8540e78b79fc5dca83d43882 (diff)
downloadtoolchain-utils-944674b1e3c67d53b802337ae4bc7d11c269f652.tar.gz
crosperf: fix lint errors.
BUG=chromium:570454 TEST=it is lint clean. Change-Id: I6d13788e7f5f75c2c2478e9d9b1343e21b56e53f Reviewed-on: https://chrome-internal-review.googlesource.com/242947 Commit-Queue: Yunlian Jiang <yunlian@google.com> Trybot-Ready: Yunlian Jiang <yunlian@google.com> Tested-by: Yunlian Jiang <yunlian@google.com> Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'crosperf/download_images_unittest.py')
-rwxr-xr-xcrosperf/download_images_unittest.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/crosperf/download_images_unittest.py b/crosperf/download_images_unittest.py
index 237369b7..2cb79a15 100755
--- a/crosperf/download_images_unittest.py
+++ b/crosperf/download_images_unittest.py
@@ -1,7 +1,11 @@
-#!/usr/bin/python
+#!/usr/bin/python2
#
# Copyright 2014 Google Inc. All Rights Reserved
+"""Download image unittest."""
+
+from __future__ import print_function
+
import os
import mock
import unittest
@@ -16,6 +20,13 @@ MOCK_LOGGER = logger.GetLogger(log_dir='', mock=True)
class ImageDownloaderTestcast(unittest.TestCase):
+ """The image downloader test class."""
+
+ def __init__(self, *args, **kwargs):
+ super(ImageDownloaderTestcast, self).__init__(*args, **kwargs)
+ self.called_download_image = False
+ self.called_uncompress_image = False
+ self.called_get_build_id = False
@mock.patch.object(os, 'makedirs')
@mock.patch.object(os.path, 'exists')
@@ -39,7 +50,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Verify os.path.exists was called twice, with proper arguments.
self.assertEqual(mock_path_exists.call_count, 2)
mock_path_exists.assert_called_with(
- '/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0/chromiumos_test_image.bin')
+ '/usr/local/home/chromeos/chroot/tmp/lumpy-release/'
+ 'R36-5814.0.0/chromiumos_test_image.bin')
mock_path_exists.assert_any_call(
'/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0')
@@ -53,7 +65,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
mock_cmd_exec.ChrootRunCommand.assert_called_with(
'/usr/local/home/chromeos',
'gsutil cp '
- 'gs://chromeos-image-archive/lumpy-release/R36-5814.0.0/chromiumos_test_image.tar.xz'
+ 'gs://chromeos-image-archive/lumpy-release/R36-5814.0.0/'
+ 'chromiumos_test_image.tar.xz'
' /tmp/lumpy-release/R36-5814.0.0')
# Reset the velues in the mocks; set os.path.exists to always return True.
@@ -67,7 +80,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Verify os.path.exists was called twice, with proper arguments.
self.assertEqual(mock_path_exists.call_count, 2)
mock_path_exists.assert_called_with(
- '/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0/chromiumos_test_image.bin')
+ '/usr/local/home/chromeos/chroot/tmp/lumpy-release/'
+ 'R36-5814.0.0/chromiumos_test_image.bin')
mock_path_exists.assert_any_call(
'/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0')
@@ -94,7 +108,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Verify os.path.exists was called once, with correct arguments.
self.assertEqual(mock_path_exists.call_count, 1)
mock_path_exists.assert_called_with(
- '/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0/chromiumos_test_image.bin')
+ '/usr/local/home/chromeos/chroot/tmp/lumpy-release/'
+ 'R36-5814.0.0/chromiumos_test_image.bin')
# Verify ChrootRunCommand was called, with correct arguments.
self.assertEqual(mock_cmd_exec.ChrootRunCommand.call_count, 1)
@@ -112,7 +127,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
# Verify os.path.exists was called once, with correct arguments.
self.assertEqual(mock_path_exists.call_count, 1)
mock_path_exists.assert_called_with(
- '/usr/local/home/chromeos/chroot/tmp/lumpy-release/R36-5814.0.0/chromiumos_test_image.bin')
+ '/usr/local/home/chromeos/chroot/tmp/lumpy-release/'
+ 'R36-5814.0.0/chromiumos_test_image.bin')
# Verify ChrootRunCommand was not called.
self.assertEqual(mock_cmd_exec.ChrootRunCommand.call_count, 0)
@@ -134,14 +150,20 @@ class ImageDownloaderTestcast(unittest.TestCase):
return 'lumpy-release/R36-5814.0.0'
def GoodDownloadImage(root, build_id, image_path):
+ if root or build_id or image_path:
+ pass
self.called_download_image = True
return 'chromiumos_test_image.bin'
def BadDownloadImage(root, build_id, image_path):
+ if root or build_id or image_path:
+ pass
self.called_download_image = True
return None
def FakeUncompressImage(root, build_id):
+ if root or build_id:
+ pass
self.called_uncompress_image = True
return 0