Write merge_flat_configs utility to simplify merging FlatConfigLists

BUG=chromium:1073073
TEST=manual

Change-Id: I7ebb5d9b7303688cd6098f6202aa991f14658e46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2465573
Commit-Queue: Sean McAllister <smcallis@google.com>
Auto-Submit: Sean McAllister <smcallis@google.com>
Reviewed-by: Andrew Lamb <andrewlamb@chromium.org>
diff --git a/payload_utils/checker/io_utils_test.py b/payload_utils/checker/io_utils_test.py
index e2bed4c..d2da36f 100644
--- a/payload_utils/checker/io_utils_test.py
+++ b/payload_utils/checker/io_utils_test.py
@@ -12,6 +12,7 @@
 from google.protobuf import json_format
 
 from checker import io_utils
+from common import config_bundle_utils
 
 from chromiumos.config.payload.config_bundle_pb2 import ConfigBundle
 from chromiumos.config.api.program_pb2 import Program
@@ -22,6 +23,7 @@
 
   def setUp(self):
     self.config = ConfigBundle(program_list=[Program(name='TestProgram1')])
+    self.flat_config = config_bundle_utils.flatten_config(self.config)
     repo_path = tempfile.mkdtemp()
 
     os.mkdir(os.path.join(repo_path, 'generated'))
@@ -32,6 +34,13 @@
     with open(self.config_path, 'w') as f:
       print(json_output, file=f)
 
+    self.flat_config_path = os.path.join(repo_path, 'generated',
+                                         'flattened.jsonproto')
+    json_output = json_format.MessageToJson(
+        self.flat_config, sort_keys=True, use_integers_for_enums=True)
+    with open(self.flat_config_path, 'w') as f:
+      print(json_output, file=f)
+
     self.factory_path = os.path.join(repo_path, 'factory')
     os.makedirs(os.path.join(self.factory_path, 'generated'))
     self.model_sku = {"model": {"a": 1}}
@@ -44,6 +53,11 @@
     """Tests the json proto can be read."""
     self.assertEqual(io_utils.read_config(self.config_path), self.config)
 
+  def test_read_flat_config(self):
+    """Tests the json proto can be read."""
+    self.assertEqual(
+        io_utils.read_flat_config(self.flat_config_path), self.flat_config)
+
   def test_read_model_sku_json(self):
     """Tests model_sku.json can be read."""
     self.assertDictEqual(