Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / chromite / lib / binpkg_unittest.py
1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium OS 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 """Unittests for the binpkg.py module."""
7
8 from __future__ import print_function
9
10 import os
11 import sys
12
13 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
14     os.path.abspath(__file__)))))
15
16 from chromite.lib import binpkg
17 from chromite.lib import cros_test_lib
18 from chromite.lib import gs_unittest
19
20
21 class FetchTarballsTest(cros_test_lib.MockTempDirTestCase):
22   """Tests for GSContext that go over the network."""
23
24   def testFetchFakePackages(self):
25     """Pretend to fetch binary packages."""
26     gs_mock = self.StartPatcher(gs_unittest.GSContextMock())
27     gs_mock.SetDefaultCmdResult()
28     uri = 'gs://foo/bar'
29     packages_uri = '{}/Packages'.format(uri)
30     packages_file = '''URI: gs://foo
31
32 CPV: boo/baz
33 PATH boo/baz.tbz2
34 '''
35     gs_mock.AddCmdResult(['cat', packages_uri], output=packages_file)
36
37     binpkg.FetchTarballs([uri], self.tempdir)
38
39   @cros_test_lib.NetworkTest()
40   def testFetchRealPackages(self):
41     """Actually fetch a real binhost from the network."""
42     uri = 'gs://chromeos-prebuilt/board/lumpy/paladin-R37-5905.0.0-rc2/packages'
43     binpkg.FetchTarballs([uri], self.tempdir)
44
45
46 if __name__ == '__main__':
47   cros_test_lib.main()