Chromium Code Reviews| Index: scripts/slave/unittests/extract_build_test.py |
| diff --git a/scripts/slave/unittests/extract_build_test.py b/scripts/slave/unittests/extract_build_test.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..06dba13caa054700dfe942dbe124a78300a37671 |
| --- /dev/null |
| +++ b/scripts/slave/unittests/extract_build_test.py |
| @@ -0,0 +1,59 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import optparse |
| +import os |
| +import unittest |
| + |
| +import test_env # pylint: disable=W0403,W0611 |
| + |
| +from slave import extract_build |
| +from slave import slave_utils |
| + |
| +_SCRIPT_DIR = os.path.dirname(__file__) |
| +_ABS_BUILD_DIR = os.path.abspath(_SCRIPT_DIR) |
| + |
| + |
| +class ExtractBuildTest(unittest.TestCase): |
| + def testGetBuildUrl(self): |
| + # Hand craft needed properties of the options object. |
| + 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
|
| + options.webkit_dir = None |
| + options.build_properties = {} |
| + options.factory_properties = {} |
| + |
| + # version_suffix is not tested, since it would just be copying of |
| + # implementation details from extract_build.py into this test. |
| + base_filename, _version_suffix = slave_utils.GetZipFileNames( |
| + options.build_properties, _ABS_BUILD_DIR, None, extract=True) |
| + |
| + gs_url_without_slash = 'gs://foo/Win' |
| + gs_url_with_slash = 'gs://foo/Win/' |
| + gs_url_with_filename = 'gs://foo/Win/%s.zip' % base_filename |
| + http_url_without_slash = 'http://foo/Win' |
| + http_url_with_slash = 'http://foo/Win/' |
| + http_url_with_filename = 'http://foo/Win/%s.zip' % base_filename |
| + expected_gs_url = gs_url_with_slash + base_filename + '.zip' |
| + expected_http_url = http_url_with_slash + base_filename + '.zip' |
| + |
| + # Verify that only one slash is added: URL without ending slash. |
| + self._VerifyBuildUrl(options, gs_url_without_slash, expected_gs_url) |
| + self._VerifyBuildUrl(options, http_url_without_slash, expected_http_url) |
| + |
| + # URL with ending slash. |
| + self._VerifyBuildUrl(options, gs_url_with_slash, expected_gs_url) |
| + self._VerifyBuildUrl(options, http_url_with_slash, expected_http_url) |
| + |
| + # URL with filename. |
| + self._VerifyBuildUrl(options, gs_url_with_filename, expected_gs_url) |
| + self._VerifyBuildUrl(options, http_url_with_filename, expected_http_url) |
| + |
| + def _VerifyBuildUrl(self, options, url_template, expected_url): |
| + options.build_url = url_template |
| + url, _versioned_url = extract_build.GetBuildUrl(_SCRIPT_DIR, options) |
| + self.assertEquals(url, expected_url) |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |