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.
6 """Unittests for the binpkg.py module."""
8 from __future__ import print_function
13 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
14 os.path.abspath(__file__)))))
16 from chromite.lib import binpkg
17 from chromite.lib import cros_test_lib
18 from chromite.lib import gs_unittest
21 class FetchTarballsTest(cros_test_lib.MockTempDirTestCase):
22 """Tests for GSContext that go over the network."""
24 def testFetchFakePackages(self):
25 """Pretend to fetch binary packages."""
26 gs_mock = self.StartPatcher(gs_unittest.GSContextMock())
27 gs_mock.SetDefaultCmdResult()
29 packages_uri = '{}/Packages'.format(uri)
30 packages_file = '''URI: gs://foo
35 gs_mock.AddCmdResult(['cat', packages_uri], output=packages_file)
37 binpkg.FetchTarballs([uri], self.tempdir)
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)
46 if __name__ == '__main__':