blob: 34d20c8c9a44f27c2a0b75961db95142c7b0c297 [file] [log] [blame]
Andrew Lambeceaec02020-02-11 14:16:41 -07001# Copyright 2020 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""Tests for io_utils."""
5
6import os
7import tempfile
8import unittest
9
10from checker import io_utils
11
Andrew Lamb31c11152020-02-14 10:00:27 -070012from bindings.src.config.proto.api.config_bundle_pb2 import ConfigBundle
13from bindings.src.config.proto.api.program_pb2 import ProgramList, Program
Andrew Lambeceaec02020-02-11 14:16:41 -070014
15
16class IoUtilsTest(unittest.TestCase):
17 """Tests for io_utils."""
18
19 def setUp(self):
20 self.config = ConfigBundle(
21 programs=ProgramList(value=[Program(name='TestProgram1')]))
22 self.repo_path = tempfile.mkdtemp()
23
24 os.mkdir(os.path.join(self.repo_path, 'generated'))
25
26 with open(
27 os.path.join(self.repo_path, 'generated', 'config.binaryproto'),
28 'wb') as f:
29 f.write(self.config.SerializeToString())
30
31 def test_read_repo_config(self):
32 """Tests the binary proto can be read."""
33 self.assertEqual(io_utils.read_repo_config(self.repo_path), self.config)