| 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..1091c4f45fbebd70e728539d4b31b51d56dce860
|
| --- /dev/null
|
| +++ b/scripts/slave/unittests/extract_build_test.py
|
| @@ -0,0 +1,60 @@
|
| +#!/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 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 MockOptions(object):
|
| + webkit_dir = None
|
| + build_properties = {}
|
| + factory_properties = {}
|
| +
|
| +
|
| +class ExtractBuildTest(unittest.TestCase):
|
| + def testGetBuildUrl(self):
|
| + options = MockOptions()
|
| +
|
| + # 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()
|
|
|