Exemplo n.º 1
0
    def test_convert_enum_int_to_string__not_an_enum(self):
        """If the property is not an enum, just use the property value."""
        actual = models.convert_enum_int_to_string('name', 'not an int')
        self.assertEqual('not an int', actual)

        actual = models.convert_enum_int_to_string('unknown property',
                                                   'something')
        self.assertEqual('something', actual)
Exemplo n.º 2
0
 def test_convert_enum_int_to_string__enum_not_found(self):
     """If we somehow don't have an emum string, use the ordinal."""
     actual = models.convert_enum_int_to_string('impl_status_chrome', 99)
     self.assertEqual(99, actual)
Exemplo n.º 3
0
 def test_convert_enum_int_to_string__enum_found(self):
     """We use the human-reable string if it is defined."""
     actual = models.convert_enum_int_to_string('impl_status_chrome',
                                                models.NO_ACTIVE_DEV)
     self.assertEqual(models.IMPLEMENTATION_STATUS[models.NO_ACTIVE_DEV],
                      actual)
Exemplo n.º 4
0
 def test_convert_enum_int_to_string__not_an_int(self):
     """We don't crash or convert when given non-numeric values."""
     actual = models.convert_enum_int_to_string(
         'impl_status_chrome', {'something': 'non-numeric'})
     self.assertEqual({'something': 'non-numeric'}, actual)