| 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 | 5 |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import StringIO | 8 import StringIO |
| 9 import sys | 9 import sys |
| 10 import unittest | 10 import unittest |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 expected = generate_expected_json( | 184 expected = generate_expected_json( |
| 185 shards=1, | 185 shards=1, |
| 186 os_image='linux2', | 186 os_image='linux2', |
| 187 working_dir='swarm_tests', | 187 working_dir='swarm_tests', |
| 188 data_server='http://localhost:8081', | 188 data_server='http://localhost:8081', |
| 189 profile=True) | 189 profile=True) |
| 190 self.assertEqual(expected, manifest_json) | 190 self.assertEqual(expected, manifest_json) |
| 191 | 191 |
| 192 def test_process_manifest_success(self): | 192 def test_process_manifest_success(self): |
| 193 self.mock(swarm_trigger_step.run_isolated, 'url_open', MockUrlOpenNoZip) | 193 self.mock(swarm_trigger_step.net, 'url_open', MockUrlOpenNoZip) |
| 194 | 194 |
| 195 result = swarm_trigger_step.process_manifest( | 195 result = swarm_trigger_step.process_manifest( |
| 196 file_sha1=FILE_HASH, | 196 file_sha1=FILE_HASH, |
| 197 test_name=TEST_NAME, | 197 test_name=TEST_NAME, |
| 198 shards=1, | 198 shards=1, |
| 199 test_filter='*', | 199 test_filter='*', |
| 200 os_image='linux2', | 200 os_image='linux2', |
| 201 working_dir='swarm_tests', | 201 working_dir='swarm_tests', |
| 202 data_server='http://localhost:8081', | 202 data_server='http://localhost:8081', |
| 203 swarm_url='http://localhost:8082', | 203 swarm_url='http://localhost:8082', |
| 204 verbose=False, | 204 verbose=False, |
| 205 profile=False, | 205 profile=False, |
| 206 priority=101) | 206 priority=101) |
| 207 self.assertEqual(0, result) | 207 self.assertEqual(0, result) |
| 208 | 208 |
| 209 # Just assert it printed enough, since it contains variable output. | 209 # Just assert it printed enough, since it contains variable output. |
| 210 out = sys.stdout.getvalue() | 210 out = sys.stdout.getvalue() |
| 211 self.assertTrue(len(out) > STDOUT_FOR_TRIGGER_LEN) | 211 self.assertTrue(len(out) > STDOUT_FOR_TRIGGER_LEN) |
| 212 self.assertTrue('Zip file not on server, starting uploading.' in out) | 212 self.assertTrue('Zip file not on server, starting uploading.' in out) |
| 213 self.mock(sys, 'stdout', StringIO.StringIO()) | 213 self.mock(sys, 'stdout', StringIO.StringIO()) |
| 214 | 214 |
| 215 def test_process_manifest_success_zip_already_uploaded(self): | 215 def test_process_manifest_success_zip_already_uploaded(self): |
| 216 self.mock(swarm_trigger_step.run_isolated, 'url_open', MockUrlOpenHasZip) | 216 self.mock(swarm_trigger_step.net, 'url_open', MockUrlOpenHasZip) |
| 217 | 217 |
| 218 result = swarm_trigger_step.process_manifest( | 218 result = swarm_trigger_step.process_manifest( |
| 219 file_sha1=FILE_HASH, | 219 file_sha1=FILE_HASH, |
| 220 test_name=TEST_NAME, | 220 test_name=TEST_NAME, |
| 221 shards=1, | 221 shards=1, |
| 222 test_filter='*', | 222 test_filter='*', |
| 223 os_image='linux2', | 223 os_image='linux2', |
| 224 working_dir='swarm_tests', | 224 working_dir='swarm_tests', |
| 225 data_server='http://localhost:8081', | 225 data_server='http://localhost:8081', |
| 226 swarm_url='http://localhost:8082', | 226 swarm_url='http://localhost:8082', |
| (...skipping 30 matching lines...) Expand all Loading... |
| 257 '', | 257 '', |
| 258 'Usage: swarm_trigger_step_test.py [options]\n\n' | 258 'Usage: swarm_trigger_step_test.py [options]\n\n' |
| 259 'swarm_trigger_step_test.py: error: At least one --run_from_hash is ' | 259 'swarm_trigger_step_test.py: error: At least one --run_from_hash is ' |
| 260 'required.\n') | 260 'required.\n') |
| 261 | 261 |
| 262 | 262 |
| 263 if __name__ == '__main__': | 263 if __name__ == '__main__': |
| 264 if '-v' in sys.argv: | 264 if '-v' in sys.argv: |
| 265 unittest.TestCase.maxDiff = None | 265 unittest.TestCase.maxDiff = None |
| 266 unittest.main() | 266 unittest.main() |
| OLD | NEW |