Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import optparse | |
| 7 import os | |
| 8 import unittest | |
| 9 | |
| 10 import test_env # pylint: disable=W0403,W0611 | |
| 11 | |
| 12 from slave import extract_build | |
| 13 from slave import slave_utils | |
| 14 | |
| 15 _SCRIPT_DIR = os.path.dirname(__file__) | |
| 16 _ABS_BUILD_DIR = os.path.abspath(_SCRIPT_DIR) | |
| 17 | |
| 18 | |
| 19 class ExtractBuildTest(unittest.TestCase): | |
| 20 def testGetBuildUrl(self): | |
| 21 # Hand craft needed properties of the options object. | |
| 22 options = optparse.Values | |
|
Isaac (away)
2013/01/08 09:11:21
Thanks for adding a test. Note you could alternat
kjellander_chromium
2013/01/08 09:32:52
Ah, of course. I still have a lot of typeless prog
| |
| 23 options.webkit_dir = None | |
| 24 options.build_properties = {} | |
| 25 options.factory_properties = {} | |
| 26 | |
| 27 # version_suffix is not tested, since it would just be copying of | |
| 28 # implementation details from extract_build.py into this test. | |
| 29 base_filename, _version_suffix = slave_utils.GetZipFileNames( | |
| 30 options.build_properties, _ABS_BUILD_DIR, None, extract=True) | |
| 31 | |
| 32 gs_url_without_slash = 'gs://foo/Win' | |
| 33 gs_url_with_slash = 'gs://foo/Win/' | |
| 34 gs_url_with_filename = 'gs://foo/Win/%s.zip' % base_filename | |
| 35 http_url_without_slash = 'http://foo/Win' | |
| 36 http_url_with_slash = 'http://foo/Win/' | |
| 37 http_url_with_filename = 'http://foo/Win/%s.zip' % base_filename | |
| 38 expected_gs_url = gs_url_with_slash + base_filename + '.zip' | |
| 39 expected_http_url = http_url_with_slash + base_filename + '.zip' | |
| 40 | |
| 41 # Verify that only one slash is added: URL without ending slash. | |
| 42 self._VerifyBuildUrl(options, gs_url_without_slash, expected_gs_url) | |
| 43 self._VerifyBuildUrl(options, http_url_without_slash, expected_http_url) | |
| 44 | |
| 45 # URL with ending slash. | |
| 46 self._VerifyBuildUrl(options, gs_url_with_slash, expected_gs_url) | |
| 47 self._VerifyBuildUrl(options, http_url_with_slash, expected_http_url) | |
| 48 | |
| 49 # URL with filename. | |
| 50 self._VerifyBuildUrl(options, gs_url_with_filename, expected_gs_url) | |
| 51 self._VerifyBuildUrl(options, http_url_with_filename, expected_http_url) | |
| 52 | |
| 53 def _VerifyBuildUrl(self, options, url_template, expected_url): | |
| 54 options.build_url = url_template | |
| 55 url, _versioned_url = extract_build.GetBuildUrl(_SCRIPT_DIR, options) | |
| 56 self.assertEquals(url, expected_url) | |
| 57 | |
| 58 if __name__ == '__main__': | |
| 59 unittest.main() | |
| OLD | NEW |