diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/rackspace/rackspace/resources/cloudnetworks.py | 3 | ||||
-rw-r--r-- | contrib/rackspace/rackspace/tests/test_cloudnetworks.py | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/contrib/rackspace/rackspace/resources/cloudnetworks.py b/contrib/rackspace/rackspace/resources/cloudnetworks.py index ffecba3fa..1eb0a9d6d 100644 --- a/contrib/rackspace/rackspace/resources/cloudnetworks.py +++ b/contrib/rackspace/rackspace/resources/cloudnetworks.py @@ -124,6 +124,9 @@ class CloudNetwork(resource.Resource): self.cloud_networks().get(self.resource_id) def check_delete_complete(self, cookie): + if not self.resource_id: + return True + try: network = self.cloud_networks().get(self.resource_id) except NotFound: diff --git a/contrib/rackspace/rackspace/tests/test_cloudnetworks.py b/contrib/rackspace/rackspace/tests/test_cloudnetworks.py index d3fb64748..f44e68c60 100644 --- a/contrib/rackspace/rackspace/tests/test_cloudnetworks.py +++ b/contrib/rackspace/rackspace/tests/test_cloudnetworks.py @@ -74,6 +74,15 @@ class FakeClient(object): pass +class FakeClientRaiseException(FakeClient): + + def create(self, label=None, cidr=None): + raise Exception + + def get(self, nwid): + raise Exception + + @mock.patch.object(cloudnetworks.CloudNetwork, "cloud_networks") class CloudNetworkTest(common.HeatTestCase): @@ -147,6 +156,18 @@ class CloudNetworkTest(common.HeatTestCase): exc = self.assertRaises(NotFound, self.fake_cnw.get, res_id) self.assertIn(res_id, six.text_type(exc)) + def test_delete_no_network_created(self, mock_client): + self.fake_cnw = FakeClientRaiseException() + mock_client.return_value = self.fake_cnw + self._parse_stack() + self.stack.create() + self.assertEqual((self.stack.CREATE, self.stack.FAILED), + self.stack.state) + res = self.stack['cnw'] + self.assertEqual((res.CREATE, res.FAILED), res.state) + scheduler.TaskRunner(res.delete)() + self.assertEqual((res.DELETE, res.COMPLETE), res.state) + def test_delete_in_use(self, mock_client): self._setup_stack(mock_client) res = self.stack['cnw'] |