Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
  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)
Пример #4
0
 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)
Пример #5
0
    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)
Пример #6
0
    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)