def conf_handler(key, value): if key == "features.connection.listingType": return conf.parse_enum(key, value, Listing) elif key == "features.connection.refreshRate": return max(1, value) elif key == "features.connection.order": return conf.parse_enum_csv(key, value[0], entries.SortAttr, 3)
def test_parse_enum(self): """ Tests the parse_enum function. """ Insects = stem.util.enum.Enum('BUTTERFLY', 'LADYBUG', 'CRICKET') self.assertEqual(Insects.LADYBUG, parse_enum('my_option', 'ladybug', Insects)) self.assertRaises(ValueError, parse_enum, 'my_option', 'ugabuga', Insects) self.assertRaises(ValueError, parse_enum, 'my_option', 'ladybug, cricket', Insects)
def test_parse_enum(self): """ Tests the parse_enum function. """ Insects = stem.util.enum.Enum("BUTTERFLY", "LADYBUG", "CRICKET") self.assertEqual(Insects.LADYBUG, parse_enum("my_option", "ladybug", Insects)) self.assertRaises(ValueError, parse_enum, "my_option", "ugabuga", Insects) self.assertRaises(ValueError, parse_enum, "my_option", "ladybug, cricket", Insects)