| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # pylint: disable=W0212 | 5 # pylint: disable=W0212 |
| 6 | 6 |
| 7 """Unit tests for download_from_google_storage.py.""" | 7 """Unit tests for download_from_google_storage.py.""" |
| 8 | 8 |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 def cleanUp(self): | 68 def cleanUp(self): |
| 69 shutil.rmtree(self.temp_dir) | 69 shutil.rmtree(self.temp_dir) |
| 70 | 70 |
| 71 def test_gsutil(self): | 71 def test_gsutil(self): |
| 72 gsutil = download_from_google_storage.Gsutil(GSUTIL_DEFAULT_PATH, None) | 72 gsutil = download_from_google_storage.Gsutil(GSUTIL_DEFAULT_PATH, None) |
| 73 self.assertEqual(gsutil.path, GSUTIL_DEFAULT_PATH) | 73 self.assertEqual(gsutil.path, GSUTIL_DEFAULT_PATH) |
| 74 code, _, err = gsutil.check_call() | 74 code, _, err = gsutil.check_call() |
| 75 self.assertEqual(code, 0) | 75 self.assertEqual(code, 0) |
| 76 self.assertEqual(err, '') | 76 self.assertEqual(err, '') |
| 77 | 77 |
| 78 def test_gsutil_version(self): | |
| 79 gsutil = download_from_google_storage.Gsutil(GSUTIL_DEFAULT_PATH, None) | |
| 80 _, _, err = gsutil.check_call('version') | |
| 81 err_lines = err.splitlines() | |
| 82 self.assertEqual(err_lines[0], 'gsutil version 3.25') | |
| 83 self.assertEqual( | |
| 84 err_lines[1], | |
| 85 'checksum c9cffb512f467c0aa54880788b9ee6ca (OK)') | |
| 86 | |
| 87 def test_get_sha1(self): | 78 def test_get_sha1(self): |
| 88 lorem_ipsum = os.path.join(self.base_path, 'lorem_ipsum.txt') | 79 lorem_ipsum = os.path.join(self.base_path, 'lorem_ipsum.txt') |
| 89 self.assertEqual( | 80 self.assertEqual( |
| 90 download_from_google_storage.get_sha1(lorem_ipsum), | 81 download_from_google_storage.get_sha1(lorem_ipsum), |
| 91 '7871c8e24da15bad8b0be2c36edc9dc77e37727f') | 82 '7871c8e24da15bad8b0be2c36edc9dc77e37727f') |
| 92 | 83 |
| 93 def test_get_md5(self): | 84 def test_get_md5(self): |
| 94 lorem_ipsum = os.path.join(self.base_path, 'lorem_ipsum.txt') | 85 lorem_ipsum = os.path.join(self.base_path, 'lorem_ipsum.txt') |
| 95 self.assertEqual( | 86 self.assertEqual( |
| 96 upload_to_google_storage.get_md5(lorem_ipsum), | 87 upload_to_google_storage.get_md5(lorem_ipsum), |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 ('check_call', | 284 ('check_call', |
| 294 ('ls', | 285 ('ls', |
| 295 '-L', | 286 '-L', |
| 296 'gs://sometesturl/7871c8e24da15bad8b0be2c36edc9dc77e37727f'))) | 287 'gs://sometesturl/7871c8e24da15bad8b0be2c36edc9dc77e37727f'))) |
| 297 self.assertEqual(self.gsutil.history, expected_calls) | 288 self.assertEqual(self.gsutil.history, expected_calls) |
| 298 self.assertEqual(code, 0) | 289 self.assertEqual(code, 0) |
| 299 | 290 |
| 300 | 291 |
| 301 if __name__ == '__main__': | 292 if __name__ == '__main__': |
| 302 unittest.main() | 293 unittest.main() |
| OLD | NEW |