| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 import test_env # pylint: disable=W0403,W0611 | 10 import test_env # pylint: disable=W0403,W0611 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 self.assertTrue(build_revision > 0) | 107 self.assertTrue(build_revision > 0) |
| 108 self.assertTrue(webkit_revision > 0) | 108 self.assertTrue(webkit_revision > 0) |
| 109 | 109 |
| 110 def testRevisionDir(self): | 110 def testRevisionDir(self): |
| 111 (build_revision, webkit_revision) = slave_utils.GetBuildRevisions( | 111 (build_revision, webkit_revision) = slave_utils.GetBuildRevisions( |
| 112 _BUILD_DIR, revision_dir=_BUILD_DIR) | 112 _BUILD_DIR, revision_dir=_BUILD_DIR) |
| 113 self.assertTrue(build_revision > 0) | 113 self.assertTrue(build_revision > 0) |
| 114 self.assertEquals(None, webkit_revision) | 114 self.assertEquals(None, webkit_revision) |
| 115 | 115 |
| 116 | 116 |
| 117 @mock.patch('__main__.slave_utils.GSUtilSetup', |
| 118 mock.MagicMock(return_value='/mock/gsutil')) |
| 119 @mock.patch('__main__.chromium_utils.RunCommand') |
| 117 class TestGSUtil(unittest.TestCase): | 120 class TestGSUtil(unittest.TestCase): |
| 118 @mock.patch('__main__.slave_utils.GSUtilSetup', return_value='/mock/gsutil') | 121 |
| 119 @mock.patch('__main__.chromium_utils.RunCommand') | |
| 120 def testGSUtilCopyCacheControl(self, # pylint: disable=R0201 | 122 def testGSUtilCopyCacheControl(self, # pylint: disable=R0201 |
| 121 run_command_mock, gs_util_setup_mock): | 123 run_command_mock): |
| 122 slave_utils.GSUtilCopyFile('foo', 'bar', | 124 slave_utils.GSUtilCopyFile('foo', 'bar', cache_control='mock_cache') |
| 123 cache_control='mock_cache') | 125 run_command_mock.assert_called_with([ |
| 124 run_command_mock.assert_called_with(['/mock/gsutil', '-h', | 126 '/mock/gsutil', |
| 125 'Cache-Control:mock_cache', 'cp', 'file://foo', | 127 '-h', |
| 126 'file://bar/foo']) | 128 'Cache-Control:mock_cache', |
| 127 slave_utils.GSUtilCopyDir('foo', 'bar', | 129 'cp', |
| 128 cache_control='mock_cache') | 130 'file://foo', |
| 129 run_command_mock.assert_called_with(['/mock/gsutil', '-m', '-h', | 131 'file://bar/foo', |
| 130 'Cache-Control:mock_cache', 'cp', '-R', 'foo', 'bar']) | 132 ]) |
| 133 slave_utils.GSUtilCopyDir('foo', 'bar', cache_control='mock_cache') |
| 134 run_command_mock.assert_called_with([ |
| 135 '/mock/gsutil', |
| 136 '-m', |
| 137 '-h', |
| 138 'Cache-Control:mock_cache', |
| 139 'cp', |
| 140 '-R', |
| 141 'foo', |
| 142 'bar', |
| 143 ]) |
| 144 |
| 145 def testGSUtilCopyFileWithDestFilename(self, # pylint: disable=R0201 |
| 146 run_command_mock): |
| 147 slave_utils.GSUtilCopyFile( |
| 148 '/my/local/path/foo.txt', 'gs://bucket/dest/dir', |
| 149 dest_filename='bar.txt') |
| 150 run_command_mock.assert_called_with([ |
| 151 '/mock/gsutil', |
| 152 'cp', |
| 153 'file:///my/local/path/foo.txt', |
| 154 'gs://bucket/dest/dir/bar.txt', |
| 155 ]) |
| 131 | 156 |
| 132 | 157 |
| 133 class GetGitRevisionTest(unittest.TestCase): | 158 class GetGitRevisionTest(unittest.TestCase): |
| 134 """Tests related to getting revisions from a directory.""" | 159 """Tests related to getting revisions from a directory.""" |
| 135 def test_GitSvnCase(self): | 160 def test_GitSvnCase(self): |
| 136 # pylint: disable=W0212 | 161 # pylint: disable=W0212 |
| 137 self.assertEqual(slave_utils._GetGitCommitPositionFromLog(CHROMIUM_LOG), | 162 self.assertEqual(slave_utils._GetGitCommitPositionFromLog(CHROMIUM_LOG), |
| 138 '291141') | 163 '291141') |
| 139 # pylint: disable=W0212 | 164 # pylint: disable=W0212 |
| 140 self.assertEqual(slave_utils._GetGitCommitPositionFromLog(BLINK_LOG), | 165 self.assertEqual(slave_utils._GetGitCommitPositionFromLog(BLINK_LOG), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 161 versions = slave_utils.GetPerfDashboardRevisions( | 186 versions = slave_utils.GetPerfDashboardRevisions( |
| 162 build_properties, revision, webkit_revision, point_id) | 187 build_properties, revision, webkit_revision, point_id) |
| 163 self.assertEqual( | 188 self.assertEqual( |
| 164 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354', | 189 {'rev': '294850', 'webkit_rev': '34f9d01', 'git_revision': '9a7b354', |
| 165 'point_id': 1470050195}, | 190 'point_id': 1470050195}, |
| 166 versions) | 191 versions) |
| 167 | 192 |
| 168 | 193 |
| 169 if __name__ == '__main__': | 194 if __name__ == '__main__': |
| 170 unittest.main() | 195 unittest.main() |
| OLD | NEW |