def test_single_override_is_parsed(self):
        parser = OverrideParser(inf_contents=SAMPLE_DATA_SINGLE_OVERRIDE)

        self.assertEqual(len(parser.override_lines), 1)
        self.assertEqual(len(parser.overrides), 1)

        self.assertEqual(parser.overrides[0]['version'], 1)
        self.assertEqual(parser.overrides[0]['original_path'].upper(),
                         os.path.normpath('MY/PATH/1'))
        self.assertEqual(parser.overrides[0]['current_hash'].upper(),
                         '4E367990B327501D1EA6FBEE4002F9C8')
        self.assertEqual(parser.overrides[0]['datetime'].year, 2018)
        self.assertEqual(parser.overrides[0]['datetime'].month, 11)
        self.assertEqual(parser.overrides[0]['datetime'].day, 27)
    def test_mixed_case_override_is_parsed(self):
        parser = OverrideParser(inf_contents=SAMPLE_DATA_MIXED_CASE_OVERRIDE)

        self.assertEqual(len(parser.override_lines), 3)
        self.assertEqual(len(parser.overrides), 3)

        self.assertEqual(parser.overrides[0]['version'], 1)
        self.assertEqual(parser.overrides[0]['current_hash'].upper(),
                         '4E367990B327501D1EA6FBEE4002F9C8')
        self.assertEqual(parser.overrides[1]['version'], 1)
        self.assertEqual(parser.overrides[1]['current_hash'].upper(),
                         '4E367990B327501D1EA6FBEE4002F9C8')
        self.assertEqual(parser.overrides[2]['version'], 1)
        self.assertEqual(parser.overrides[2]['current_hash'].upper(),
                         '4E367990B327501D1EA6FBEE4002F9C8')
    def test_real_world_override_is_parsed(self):
        parser = OverrideParser(inf_contents=SAMPLE_DATA_REAL_WORLD)

        self.assertEqual(len(parser.override_lines), 1)
        self.assertEqual(len(parser.overrides), 1)

        self.assertEqual(parser.overrides[0]['version'], 1)
        self.assertEqual(
            parser.overrides[0]['original_path'],
            os.path.normpath(
                'MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf')
        )
        self.assertEqual(parser.overrides[0]['current_hash'].upper(),
                         '2EBA0BC48B8AB3B1399C26800D057102')
        self.assertEqual(parser.overrides[0]['datetime'].year, 2018)
        self.assertEqual(parser.overrides[0]['datetime'].month, 10)
        self.assertEqual(parser.overrides[0]['datetime'].day, 5)
 def test_bad_version_or_bad_date_raises_error(self):
     with self.assertRaises(ValueError):
         OverrideParser(inf_contents=SAMPLE_DATA_BAD_VERSION)
     with self.assertRaises(ValueError):
         OverrideParser(inf_contents=SAMPLE_DATA_BAD_DATE)
 def test_no_overrides_raises_error(self):
     with self.assertRaises(ValueError):
         OverrideParser(inf_contents=SAMPLE_DATA_NO_OVERRIDE)
 def test_no_inputs_raises_error(self):
     with self.assertRaises(ValueError):
         OverrideParser()