diff options
author | Dan Albert <danalbert@google.com> | 2015-11-17 13:47:16 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2015-11-17 13:47:16 -0800 |
commit | a14a4add9d8e72c10f68f50adde4d73c299f186f (patch) | |
tree | c19277787d3fdf604f54d73b571c0fc848ced12c /lib/cros_build_lib_unittest.py | |
parent | f9a912f6cfbc0c8e9419cafb0c7b1698926dce5f (diff) | |
parent | 691026242b81aceac4805322e2a51cb5ccbb6766 (diff) | |
download | chromite-a14a4add9d8e72c10f68f50adde4d73c299f186f.tar.gz |
Merge to upstream 691026242b81aceac4805322e2a51cb5ccbb6766HEADndk-r11cndk-r11bndk-r11ndk-r11-releasemastermainbrillo-m10-releasebrillo-m10-dev
Diffstat (limited to 'lib/cros_build_lib_unittest.py')
-rw-r--r-- | lib/cros_build_lib_unittest.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py index 87167ea11..24c750755 100644 --- a/lib/cros_build_lib_unittest.py +++ b/lib/cros_build_lib_unittest.py @@ -1330,6 +1330,26 @@ class TestManifestCheckout(cros_test_lib.TempDirTestCase): self.assertEqual(branches, ['refs/remotes/origin/release-R23-2913.B']) +class TestGroupByKey(cros_test_lib.TestCase): + """Test SplitByKey.""" + + def testEmpty(self): + self.assertEqual({}, cros_build_lib.GroupByKey([], '')) + + def testGroupByKey(self): + input_iter = [{'a': None, 'b': 0}, + {'a': 1, 'b': 1}, + {'a': 2, 'b': 2}, + {'a': 1, 'b': 3}] + expected_result = { + None: [{'a': None, 'b': 0}], + 1: [{'a': 1, 'b': 1}, + {'a': 1, 'b': 3}], + 2: [{'a': 2, 'b': 2}]} + self.assertEqual(cros_build_lib.GroupByKey(input_iter, 'a'), + expected_result) + + class Test_iflatten_instance(cros_test_lib.TestCase): """Test iflatten_instance function.""" |