From a38a8e73dd9aed35d2ddd2ddff6505e4bb791699 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Mon, 17 Jun 2013 12:24:50 +0200 Subject: [PATCH] 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 --- heat/tests/test_s3.py | 11 +---------- heat/tests/test_swift.py | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py index 76576134..3717d495 100644 --- a/heat/tests/test_s3.py +++ b/heat/tests/test_s3.py @@ -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() diff --git a/heat/tests/test_swift.py b/heat/tests/test_swift.py index 6b9b2e81..efb1c842 100644 --- a/heat/tests/test_swift.py +++ b/heat/tests/test_swift.py @@ -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() -- 2.45.2