Fix bizarre Swift DeletionPolicy unit tests

If something shouldn't be called... don't tell the mocks to expect it to be
called. We will get UnexpectedMethodCallError if it is.

Change-Id: I61a7b77cb273b42177a37efa98fc62fd69770545
This commit is contained in:
Zane Bitter 2013-06-17 12:24:50 +02:00
parent 560804e428
commit a38a8e73dd
2 changed files with 2 additions and 20 deletions

View File

@ -208,9 +208,6 @@ class s3Test(HeatTestCase):
mox.Regex(self.container_pattern),
{'X-Container-Write': 'test_tenant:test_username',
'X-Container-Read': 'test_tenant:test_username'}).AndReturn(None)
# This should not be called
swiftclient.Connection.delete_container(
mox.Regex(self.container_pattern)).AndReturn(None)
self.m.ReplayAll()
t = template_format.parse(swift_template)
@ -219,13 +216,7 @@ class s3Test(HeatTestCase):
bucket['DeletionPolicy'] = 'Retain'
stack = parse_stack(t)
rsrc = self.create_resource(t, stack, 'S3Bucket')
# if delete_container is called, mox verify will succeed
rsrc.delete()
self.assertEqual(rsrc.DELETE_COMPLETE, rsrc.state)
try:
self.m.VerifyAll()
except mox.ExpectedMethodCallsError:
return
raise Exception('delete_container was called despite Retain policy')
self.m.VerifyAll()

View File

@ -235,9 +235,6 @@ class swiftTest(HeatTestCase):
mox.Regex(self.container_pattern),
{'X-Container-Write': None,
'X-Container-Read': None}).AndReturn(None)
# This should not be called
swiftclient.Connection.delete_container(
mox.Regex(self.container_pattern)).AndReturn(None)
self.m.ReplayAll()
t = template_format.parse(swift_template)
@ -246,13 +243,7 @@ class swiftTest(HeatTestCase):
container['DeletionPolicy'] = 'Retain'
stack = parse_stack(t)
rsrc = self.create_resource(t, stack, 'SwiftContainer')
# if delete_container is called, mox verify will succeed
rsrc.delete()
self.assertEqual(rsrc.DELETE_COMPLETE, rsrc.state)
try:
self.m.VerifyAll()
except mox.ExpectedMethodCallsError:
return
raise Exception('delete_container was called despite Retain policy')
self.m.VerifyAll()