entry_test.py 873 B

123456789101112131415161718192021222324252627
  1. #
  2. # Copyright (c) 2016 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. # Test for the Entry class
  8. import collections
  9. import unittest
  10. import entry
  11. class TestEntry(unittest.TestCase):
  12. def testEntryContents(self):
  13. """Test the Entry bass class"""
  14. base_entry = entry.Entry(None, None, None, read_node=False)
  15. self.assertEqual(True, base_entry.ObtainContents())
  16. def testUnknownEntry(self):
  17. """Test that unknown entry types are detected"""
  18. Node = collections.namedtuple('Node', ['name', 'path'])
  19. node = Node('invalid-name', 'invalid-path')
  20. with self.assertRaises(ValueError) as e:
  21. entry.Entry.Create(None, node, node.name)
  22. self.assertIn("Unknown entry type 'invalid-name' in node "
  23. "'invalid-path'", str(e.exception))