Merge "Use o.vo FlexibleBooleanField"

This commit is contained in:
Jenkins 2015-11-25 05:18:41 +00:00 committed by Gerrit Code Review
commit 93510d56d0
2 changed files with 1 additions and 35 deletions

View File

@ -15,7 +15,6 @@
from collections import OrderedDict
import netaddr
from oslo_utils import strutils
from oslo_versionedobjects import fields
import six
@ -57,6 +56,7 @@ DictProxyField = fields.DictProxyField
ObjectField = fields.ObjectField
ListOfObjectsField = fields.ListOfObjectsField
VersionPredicateField = fields.VersionPredicateField
FlexibleBooleanField = fields.FlexibleBooleanField
# NOTE(danms): These are things we need to import for some of our
@ -413,13 +413,6 @@ class PciDeviceType(Enum):
valid_values=PciDeviceType.ALL)
# NOTE(danms): Remove this on next release of oslo.versionedobjects
class FlexibleBoolean(fields.Boolean):
@staticmethod
def coerce(obj, attr, value):
return strutils.bool_from_string(value)
class IPAddress(FieldType):
@staticmethod
def coerce(obj, attr, value):
@ -662,16 +655,6 @@ class PciDeviceTypeField(BaseEnumField):
AUTO_TYPE = PciDeviceType()
# FIXME(danms): Remove this after oslo.versionedobjects gets it
# This is a flexible interpretation of boolean
# values using common user friendly semantics for
# truth/falsehood. ie strings like 'yes', 'no',
# 'on', 'off', 't', 'f' get mapped to values you
# would expect.
class FlexibleBooleanField(AutoTypedField):
AUTO_TYPE = FlexibleBoolean()
class IPAddressField(AutoTypedField):
AUTO_TYPE = IPAddress()

View File

@ -627,23 +627,6 @@ class TestBoolean(TestField):
self.from_primitive_values = self.coerce_good_values[0:2]
class TestFlexibleBoolean(TestField):
def setUp(self):
super(TestFlexibleBoolean, self).setUp()
self.field = fields.FlexibleBooleanField()
self.coerce_good_values = [(True, True), (False, False),
("true", True), ("false", False),
("t", True), ("f", False),
("yes", True), ("no", False),
("y", True), ("n", False),
("on", True), ("off", False),
(1, True), (0, False),
('frog', False), ('', False)]
self.coerce_bad_values = []
self.to_primitive_values = self.coerce_good_values[0:2]
self.from_primitive_values = self.coerce_good_values[0:2]
class TestDateTime(TestField):
def setUp(self):
super(TestDateTime, self).setUp()