Correct Resource.id deleter property
The id.deleter method being named id_del meant that it wasn't actually responding to "del id". The method has to be called "id" as well, so it's now named that and there's a test for it. Change-Id: I3101fe68d3d77458dc6590576bfadc1581e4e4dd
This commit is contained in:
@@ -249,7 +249,7 @@ class Resource(collections.MutableMapping):
|
||||
return self._attrs.get(self.id_attribute, None)
|
||||
|
||||
@id.deleter
|
||||
def id_del(self):
|
||||
def id(self):
|
||||
del self._attrs[self.id_attribute]
|
||||
|
||||
@property
|
||||
|
||||
@@ -302,6 +302,18 @@ class ResourceTests(base.TestTransportBase):
|
||||
except AttributeError:
|
||||
self.fail("third was not found in fallback as expected")
|
||||
|
||||
def test_id_del(self):
|
||||
|
||||
class Test(resource.Resource):
|
||||
id_attribute = "my_id"
|
||||
|
||||
attrs = {"my_id": 100}
|
||||
t = Test(attrs=attrs)
|
||||
|
||||
self.assertEqual(t.id, attrs["my_id"])
|
||||
del t.id
|
||||
self.assertTrue(Test.id_attribute not in t._attrs)
|
||||
|
||||
|
||||
class FakeResponse:
|
||||
def __init__(self, response):
|
||||
|
||||
Reference in New Issue
Block a user