Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / chromite / scripts / cros_list_modified_packages_unittest.py
1 #!/usr/bin/python
2 # Copyright 2014 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 """Unit tests for the cros_list_modified_packages program"""
7
8 from __future__ import print_function
9
10 import functools
11 import os
12 import sys
13
14 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
15     os.path.abspath(__file__)))))
16
17 from chromite.lib import cros_test_lib
18 from chromite.scripts import cros_list_modified_packages
19
20
21 class ListModifiedWorkonPackagesTest(cros_test_lib.MockTestCase):
22   """Test for cros_list_modified_packages.ListModifiedWorkonPackages."""
23
24   def testListModifiedWorkonPackages(self):
25     """Test that no ebuild breaks cros_list_modified_packages"""
26
27     # A hook to set the "all_opt" parameter when calling ListWorkonPackages
28     _ListWorkonPackagesPatch = \
29       functools.partial(cros_list_modified_packages.ListWorkonPackages,
30                         all_opt=True)
31
32     with self.PatchObject(cros_list_modified_packages, 'ListWorkonPackages',
33                           side_effect=_ListWorkonPackagesPatch):
34       # ListModifiedWorkonPackages returns a generator object and doesn't
35       # actually do any work automatically. We have to extract the elements
36       # from it to get it to exercise the code, and we can do that by turning
37       # it into a list.
38       list(cros_list_modified_packages.ListModifiedWorkonPackages(None, True))
39
40
41 if __name__ == '__main__':
42   cros_test_lib.main()