openstack.format: Remove 'serialize' classmethod
This is not used anywhere. Drop it. A release note is included although it likely isn't necessary since this will have no effect as again we weren't using this. Change-Id: I3878216a12a387c9c30fcbadad4da0019612fc5a Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
f9bea72ac5
commit
3163c7597d
@ -12,11 +12,6 @@
|
|||||||
|
|
||||||
|
|
||||||
class Formatter:
|
class Formatter:
|
||||||
@classmethod
|
|
||||||
def serialize(cls, value):
|
|
||||||
"""Return a string representing the formatted value"""
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def deserialize(cls, value):
|
def deserialize(cls, value):
|
||||||
"""Return a formatted object representing the value"""
|
"""Return a formatted object representing the value"""
|
||||||
@ -36,14 +31,3 @@ class BoolStr(Formatter):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Unable to deserialize boolean string: %s" % value
|
"Unable to deserialize boolean string: %s" % value
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def serialize(cls, value):
|
|
||||||
"""Convert a boolean to a boolean string"""
|
|
||||||
if isinstance(value, bool):
|
|
||||||
if value:
|
|
||||||
return "true"
|
|
||||||
else:
|
|
||||||
return "false"
|
|
||||||
else:
|
|
||||||
raise ValueError("Unable to serialize boolean string: %s" % value)
|
|
||||||
|
@ -28,11 +28,3 @@ class HREFToUUID(format.Formatter):
|
|||||||
|
|
||||||
# The UUID will be the last portion of the URI.
|
# The UUID will be the last portion of the URI.
|
||||||
return parts.path.split("/")[-1]
|
return parts.path.split("/")[-1]
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def serialize(cls, value):
|
|
||||||
# NOTE(briancurtin): If we had access to the session to get
|
|
||||||
# the endpoint we could do something smart here like take an ID
|
|
||||||
# and give back an HREF, but this will just have to be something
|
|
||||||
# that works different because Barbican does what it does...
|
|
||||||
return value
|
|
||||||
|
@ -27,10 +27,3 @@ class TestBoolStrFormatter(base.TestCase):
|
|||||||
self.assertRaises(ValueError, format.BoolStr.deserialize, None)
|
self.assertRaises(ValueError, format.BoolStr.deserialize, None)
|
||||||
self.assertRaises(ValueError, format.BoolStr.deserialize, '')
|
self.assertRaises(ValueError, format.BoolStr.deserialize, '')
|
||||||
self.assertRaises(ValueError, format.BoolStr.deserialize, 'INVALID')
|
self.assertRaises(ValueError, format.BoolStr.deserialize, 'INVALID')
|
||||||
|
|
||||||
def test_serialize(self):
|
|
||||||
self.assertEqual('true', format.BoolStr.serialize(True))
|
|
||||||
self.assertEqual('false', format.BoolStr.serialize(False))
|
|
||||||
self.assertRaises(ValueError, format.BoolStr.serialize, None)
|
|
||||||
self.assertRaises(ValueError, format.BoolStr.serialize, '')
|
|
||||||
self.assertRaises(ValueError, format.BoolStr.serialize, 'True')
|
|
||||||
|
@ -204,10 +204,6 @@ class TestComponent(base.TestCase):
|
|||||||
class FakeFormatter(format.Formatter):
|
class FakeFormatter(format.Formatter):
|
||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def serialize(cls, arg):
|
|
||||||
FakeFormatter.calls.append(arg)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def deserialize(cls, arg):
|
def deserialize(cls, arg):
|
||||||
FakeFormatter.calls.append(arg)
|
FakeFormatter.calls.append(arg)
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The ``openstack.format.Formatter`` class no longer defines a ``serialize``
|
||||||
|
method to override. This was unused and unneccessary complexity.
|
Loading…
x
Reference in New Issue
Block a user