'Test that we can add options.'

def testAddOption(self):

    conf = config_lib.GrrConfigManager()
    conf.DEFINE_string('Section1.foobar', 'test', 'A    test    string.')
    conf.DEFINE_string('Section1.test', 'test', 'A    test    string.')
    conf.DEFINE_string('Section1.interpolated', '', 'An    interpolated    string.')
    conf.DEFINE_integer('Section1.broken_int', 'string', 'A    test    integer.')
    conf.DEFINE_string('Section1.system', None, 'The    basic    operating    system.')
    conf.DEFINE_integer('Section1.test_int', 54, 'A    test    integer.')
    conf.DEFINE_list('Section1.test_list', ['a', 'b'], 'A    test    integer.')
    conf.DEFINE_list('Section1.test_list2', ['a', 'b'], 'A    test    integer.')
    conf.DEFINE_integer('Section2.test_int', None, 'A    test    integer.')
    conf.DEFINE_string('Section2.interpolated', '', 'An    interpolated    string.')
    conf.DEFINE_integer('Section3.test_int', None, 'A    test    integer.')
    conf.DEFINE_string('Section3.interpolated', '', 'An    interpolated    string.')
    conf.Initialize(data='\n[Section1]\nfoobar    =    X\ntest_list    =    x,y\n\n[Section2]\ntest_int    =    34\ninterpolated    =    %(Section1.foobar)Y\n\n[Section3]\ntest_int    =    1\ninterpolated    =    %(%(Section1.foobar)|lower)Y\n\n')
    errors = conf.Validate('Section1')
    self.assertIn('Invalid    value    string    for    Integer', str(errors['Section1.broken_int']))
    self.assertRaises(config_lib.UnknownOption, conf.__getitem__, 'a')
    self.assertEqual(conf['Section1.foobar'], 'X')
    self.assertEqual(conf['Section1.test_list'], ['x', 'y'])
    self.assertEqual(conf['Section1.test_list2'], ['a', 'b'])
    self.assertEqual(conf['Section1.test'], 'test')
    self.assertEqual(conf['Section2.interpolated'], 'XY')
    self.assertEqual(conf['Section1.test_int'], 54)
    self.assertEqual(conf['Section3.interpolated'], 'xY')
