~ubuntu-branches/ubuntu/trusty/heat/trusty

« back to all changes in this revision

Viewing changes to .pc/rename-quantumclient.patch/heat/tests/test_security_group.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short
  • Date: 2013-08-08 01:08:42 UTC
  • Revision ID: package-import@ubuntu.com-20130808010842-77cni2v4vlib7rus
Tags: 2013.2~b2-0ubuntu4
[ Chuck Short ]
* debian/rules: Enable testsuite during builds.
* debian/patches/fix-sqlalchemy-0.8.patch: Build against sqlalchemy 0.8.
* debian/patches/rename-quantumclient.patch: quantumclient -> neutronclient.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
#    not use this file except in compliance with the License. You may obtain
 
5
#    a copy of the License at
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
#    Unless required by applicable law or agreed to in writing, software
 
10
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
#    License for the specific language governing permissions and limitations
 
13
#    under the License.
 
14
 
 
15
import collections
 
16
 
 
17
from heat.engine import clients
 
18
from heat.common import context
 
19
from heat.common import template_format
 
20
from heat.engine import parser
 
21
from heat.engine import resource
 
22
from heat.tests.common import HeatTestCase
 
23
from heat.tests.utils import setup_dummy_db
 
24
from heat.tests.v1_1 import fakes
 
25
from heat.tests import utils
 
26
from heat.tests.utils import stack_delete_after
 
27
 
 
28
from novaclient.v1_1 import security_groups as nova_sg
 
29
from novaclient.v1_1 import security_group_rules as nova_sgr
 
30
from quantumclient.common.exceptions import QuantumClientException
 
31
from quantumclient.v2_0 import client as quantumclient
 
32
 
 
33
NovaSG = collections.namedtuple('NovaSG',
 
34
                                ' '.join([
 
35
                                    'name',
 
36
                                    'id',
 
37
                                    'rules',
 
38
                                    'description',
 
39
                                ]))
 
40
 
 
41
 
 
42
class SecurityGroupTest(HeatTestCase):
 
43
 
 
44
    test_template_nova = '''
 
45
HeatTemplateFormatVersion: '2012-12-12'
 
46
Resources:
 
47
  the_sg:
 
48
    Type: AWS::EC2::SecurityGroup
 
49
    Properties:
 
50
      GroupDescription: HTTP and SSH access
 
51
      SecurityGroupIngress:
 
52
        - IpProtocol: tcp
 
53
          FromPort: 22
 
54
          ToPort: 22
 
55
          CidrIp: 0.0.0.0/0
 
56
        - IpProtocol: tcp
 
57
          FromPort : 80
 
58
          ToPort : 80
 
59
          CidrIp : 0.0.0.0/0
 
60
'''
 
61
 
 
62
    test_template_quantum = '''
 
63
HeatTemplateFormatVersion: '2012-12-12'
 
64
Resources:
 
65
  the_sg:
 
66
    Type: AWS::EC2::SecurityGroup
 
67
    Properties:
 
68
      GroupDescription: HTTP and SSH access
 
69
      VpcId: aaaa
 
70
      SecurityGroupIngress:
 
71
        - IpProtocol: tcp
 
72
          FromPort: 22
 
73
          ToPort: 22
 
74
          CidrIp: 0.0.0.0/0
 
75
        - IpProtocol: tcp
 
76
          FromPort : 80
 
77
          ToPort : 80
 
78
          CidrIp : 0.0.0.0/0
 
79
      SecurityGroupEgress:
 
80
        - IpProtocol: tcp
 
81
          FromPort: 22
 
82
          ToPort: 22
 
83
          CidrIp: 10.0.1.0/24
 
84
'''
 
85
 
 
86
    def setUp(self):
 
87
        super(SecurityGroupTest, self).setUp()
 
88
        self.fc = fakes.FakeClient()
 
89
        self.m.StubOutWithMock(clients.OpenStackClients, 'nova')
 
90
        self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create')
 
91
        self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'delete')
 
92
        self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'create')
 
93
        self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'delete')
 
94
        self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'get')
 
95
        self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'list')
 
96
        setup_dummy_db()
 
97
        self.m.StubOutWithMock(quantumclient.Client, 'create_security_group')
 
98
        self.m.StubOutWithMock(
 
99
            quantumclient.Client, 'create_security_group_rule')
 
100
        self.m.StubOutWithMock(quantumclient.Client, 'show_security_group')
 
101
        self.m.StubOutWithMock(
 
102
            quantumclient.Client, 'delete_security_group_rule')
 
103
        self.m.StubOutWithMock(quantumclient.Client, 'delete_security_group')
 
104
 
 
105
    def create_stack(self, template):
 
106
        t = template_format.parse(template)
 
107
        self.stack = self.parse_stack(t)
 
108
        self.assertEqual(None, self.stack.create())
 
109
        return self.stack
 
110
 
 
111
    def parse_stack(self, t):
 
112
        ctx = context.RequestContext.from_dict({
 
113
            'tenant': 'test_tenant',
 
114
            'username': 'test_username',
 
115
            'password': 'password',
 
116
            'auth_url': 'http://localhost:5000/v2.0'})
 
117
        stack_name = 'test_stack'
 
118
        tmpl = parser.Template(t)
 
119
        stack = parser.Stack(ctx, stack_name, tmpl)
 
120
        stack.store()
 
121
        return stack
 
122
 
 
123
    def assertResourceState(self, rsrc, ref_id, metadata={}):
 
124
        self.assertEqual(None, rsrc.validate())
 
125
        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
 
126
        self.assertEqual(ref_id, rsrc.FnGetRefId())
 
127
        self.assertEqual(metadata, dict(rsrc.metadata))
 
128
 
 
129
    @stack_delete_after
 
130
    def test_security_group_nova(self):
 
131
        #create script
 
132
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
133
        nova_sg.SecurityGroupManager.list().AndReturn([NovaSG(
 
134
            id=1,
 
135
            name='test',
 
136
            description='FAKE_SECURITY_GROUP',
 
137
            rules=[],
 
138
        )])
 
139
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
140
        sg_name = utils.PhysName('test_stack', 'the_sg')
 
141
        nova_sg.SecurityGroupManager.create(
 
142
            sg_name,
 
143
            'HTTP and SSH access').AndReturn(NovaSG(
 
144
                id=2,
 
145
                name=sg_name,
 
146
                description='HTTP and SSH access',
 
147
                rules=[]))
 
148
 
 
149
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
150
        nova_sgr.SecurityGroupRuleManager.create(
 
151
            2, 'tcp', 22, 22, '0.0.0.0/0').AndReturn(None)
 
152
        nova_sgr.SecurityGroupRuleManager.create(
 
153
            2, 'tcp', 80, 80, '0.0.0.0/0').AndReturn(None)
 
154
 
 
155
        # delete script
 
156
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
157
        nova_sg.SecurityGroupManager.get(2).AndReturn(NovaSG(
 
158
            id=2,
 
159
            name=sg_name,
 
160
            description='HTTP and SSH access',
 
161
            rules=[{
 
162
                "from_port": 22,
 
163
                "group": {},
 
164
                "ip_protocol": "tcp",
 
165
                "to_port": 22,
 
166
                "parent_group_id": 2,
 
167
                "ip_range": {
 
168
                    "cidr": "0.0.0.0/0"
 
169
                },
 
170
                'id': 130
 
171
            }, {
 
172
                'from_port': 80,
 
173
                'group': {},
 
174
                'ip_protocol': 'tcp',
 
175
                'to_port': 80,
 
176
                'parent_group_id': 2,
 
177
                'ip_range': {
 
178
                    'cidr': '0.0.0.0/0'
 
179
                },
 
180
                'id': 131
 
181
            }]
 
182
        ))
 
183
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
184
        nova_sgr.SecurityGroupRuleManager.delete(130).AndReturn(None)
 
185
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
186
        nova_sgr.SecurityGroupRuleManager.delete(131).AndReturn(None)
 
187
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
188
        nova_sg.SecurityGroupManager.delete(2).AndReturn(None)
 
189
 
 
190
        self.m.ReplayAll()
 
191
        stack = self.create_stack(self.test_template_nova)
 
192
 
 
193
        sg = stack['the_sg']
 
194
        self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})
 
195
 
 
196
        self.assertResourceState(sg, utils.PhysName('test_stack', 'the_sg'))
 
197
 
 
198
        stack.delete()
 
199
        self.m.VerifyAll()
 
200
 
 
201
    @stack_delete_after
 
202
    def test_security_group_nova_exception(self):
 
203
        #create script
 
204
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
205
        sg_name = utils.PhysName('test_stack', 'the_sg')
 
206
        nova_sg.SecurityGroupManager.list().AndReturn([NovaSG(
 
207
            id=2,
 
208
            name=sg_name,
 
209
            description='HTTP and SSH access',
 
210
            rules=[],
 
211
        )])
 
212
 
 
213
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
214
        nova_sgr.SecurityGroupRuleManager.create(
 
215
            2, 'tcp', 22, 22, '0.0.0.0/0').AndRaise(
 
216
                clients.novaclient.exceptions.BadRequest(
 
217
                    400, 'Rule already exists'))
 
218
        nova_sgr.SecurityGroupRuleManager.create(
 
219
            2, 'tcp', 80, 80, '0.0.0.0/0').AndReturn(
 
220
                clients.novaclient.exceptions.BadRequest(
 
221
                    400, 'Rule already exists'))
 
222
 
 
223
        # delete script
 
224
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
225
        nova_sg.SecurityGroupManager.get(2).AndReturn(NovaSG(
 
226
            id=2,
 
227
            name=sg_name,
 
228
            description='HTTP and SSH access',
 
229
            rules=[{
 
230
                "from_port": 22,
 
231
                "group": {},
 
232
                "ip_protocol": "tcp",
 
233
                "to_port": 22,
 
234
                "parent_group_id": 2,
 
235
                "ip_range": {
 
236
                    "cidr": "0.0.0.0/0"
 
237
                },
 
238
                'id': 130
 
239
            }, {
 
240
                'from_port': 80,
 
241
                'group': {},
 
242
                'ip_protocol': 'tcp',
 
243
                'to_port': 80,
 
244
                'parent_group_id': 2,
 
245
                'ip_range': {
 
246
                    'cidr': '0.0.0.0/0'
 
247
                },
 
248
                'id': 131
 
249
            }]
 
250
        ))
 
251
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
252
        nova_sgr.SecurityGroupRuleManager.delete(130).AndRaise(
 
253
            clients.novaclient.exceptions.NotFound('goneburger'))
 
254
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
255
        nova_sgr.SecurityGroupRuleManager.delete(131).AndRaise(
 
256
            clients.novaclient.exceptions.NotFound('goneburger'))
 
257
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
258
        nova_sg.SecurityGroupManager.delete(2).AndReturn(None)
 
259
 
 
260
        clients.OpenStackClients.nova('compute').AndReturn(self.fc)
 
261
        nova_sg.SecurityGroupManager.get(2).AndRaise(
 
262
            clients.novaclient.exceptions.NotFound('goneburger'))
 
263
 
 
264
        self.m.ReplayAll()
 
265
        stack = self.create_stack(self.test_template_nova)
 
266
 
 
267
        sg = stack['the_sg']
 
268
        self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})
 
269
 
 
270
        self.assertResourceState(sg, utils.PhysName('test_stack', 'the_sg'))
 
271
 
 
272
        self.assertEqual(None, sg.delete())
 
273
 
 
274
        sg.state_set(sg.CREATE, sg.COMPLETE, 'to delete again')
 
275
        sg.resource_id = 2
 
276
        stack.delete()
 
277
 
 
278
        self.m.VerifyAll()
 
279
 
 
280
    @stack_delete_after
 
281
    def test_security_group_quantum(self):
 
282
        #create script
 
283
        sg_name = utils.PhysName('test_stack', 'the_sg')
 
284
        quantumclient.Client.create_security_group({
 
285
            'security_group': {
 
286
                'name': sg_name,
 
287
                'description': 'HTTP and SSH access'
 
288
            }
 
289
        }).AndReturn({
 
290
            'security_group': {
 
291
                'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
292
                'name': sg_name,
 
293
                'description': 'HTTP and SSH access',
 
294
                'security_group_rules': [],
 
295
                'id': 'aaaa'
 
296
            }
 
297
        })
 
298
 
 
299
        quantumclient.Client.create_security_group_rule({
 
300
            'security_group_rule': {
 
301
                'direction': 'ingress',
 
302
                'remote_ip_prefix': '0.0.0.0/0',
 
303
                'port_range_min': 22,
 
304
                'ethertype': 'IPv4',
 
305
                'port_range_max': 22,
 
306
                'protocol': 'tcp',
 
307
                'security_group_id': 'aaaa'
 
308
            }
 
309
        }).AndReturn({
 
310
            'security_group_rule': {
 
311
                'direction': 'ingress',
 
312
                'remote_ip_prefix': '0.0.0.0/0',
 
313
                'port_range_min': 22,
 
314
                'ethertype': 'IPv4',
 
315
                'port_range_max': 22,
 
316
                'protocol': 'tcp',
 
317
                'security_group_id': 'aaaa',
 
318
                'id': 'bbbb'
 
319
            }
 
320
        })
 
321
        quantumclient.Client.create_security_group_rule({
 
322
            'security_group_rule': {
 
323
                'direction': 'ingress',
 
324
                'remote_ip_prefix': '0.0.0.0/0',
 
325
                'port_range_min': 80,
 
326
                'ethertype': 'IPv4',
 
327
                'port_range_max': 80,
 
328
                'protocol': 'tcp',
 
329
                'security_group_id': 'aaaa'
 
330
            }
 
331
        }).AndReturn({
 
332
            'security_group_rule': {
 
333
                'direction': 'ingress',
 
334
                'remote_ip_prefix': '0.0.0.0/0',
 
335
                'port_range_min': 80,
 
336
                'ethertype': 'IPv4',
 
337
                'port_range_max': 80,
 
338
                'protocol': 'tcp',
 
339
                'security_group_id': 'aaaa',
 
340
                'id': 'cccc'
 
341
            }
 
342
        })
 
343
        quantumclient.Client.create_security_group_rule({
 
344
            'security_group_rule': {
 
345
                'direction': 'egress',
 
346
                'remote_ip_prefix': '10.0.1.0/24',
 
347
                'port_range_min': 22,
 
348
                'ethertype': 'IPv4',
 
349
                'port_range_max': 22,
 
350
                'protocol': 'tcp',
 
351
                'security_group_id': 'aaaa'
 
352
            }
 
353
        }).AndReturn({
 
354
            'security_group_rule': {
 
355
                'direction': 'egress',
 
356
                'remote_ip_prefix': '10.0.1.0/24',
 
357
                'port_range_min': 22,
 
358
                'ethertype': 'IPv4',
 
359
                'port_range_max': 22,
 
360
                'protocol': 'tcp',
 
361
                'security_group_id': 'aaaa',
 
362
                'id': 'dddd'
 
363
            }
 
364
        })
 
365
 
 
366
        # delete script
 
367
        quantumclient.Client.show_security_group('aaaa').AndReturn({
 
368
            'security_group': {
 
369
                'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
370
                'name': 'sc1',
 
371
                'description': '',
 
372
                'security_group_rules': [{
 
373
                    'direction': 'ingress',
 
374
                    'protocol': 'tcp',
 
375
                    'port_range_max': 22,
 
376
                    'id': 'bbbb',
 
377
                    'ethertype': 'IPv4',
 
378
                    'security_group_id': 'aaaa',
 
379
                    'remote_ip_prefix': '0.0.0.0/0',
 
380
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
381
                    'port_range_min': 22
 
382
                }, {
 
383
                    'direction': 'ingress',
 
384
                    'protocol': 'tcp',
 
385
                    'port_range_max': 80,
 
386
                    'id': 'cccc',
 
387
                    'ethertype': 'IPv4',
 
388
                    'security_group_id': 'aaaa',
 
389
                    'remote_ip_prefix': '0.0.0.0/0',
 
390
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
391
                    'port_range_min': 80
 
392
                }, {
 
393
                    'direction': 'egress',
 
394
                    'protocol': 'tcp',
 
395
                    'port_range_max': 22,
 
396
                    'id': 'dddd',
 
397
                    'ethertype': 'IPv4',
 
398
                    'security_group_id': 'aaaa',
 
399
                    'remote_ip_prefix': '10.0.1.0/24',
 
400
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
401
                    'port_range_min': 22
 
402
                }],
 
403
                'id': 'aaaa'}})
 
404
        quantumclient.Client.delete_security_group_rule('bbbb').AndReturn(None)
 
405
        quantumclient.Client.delete_security_group_rule('cccc').AndReturn(None)
 
406
        quantumclient.Client.delete_security_group_rule('dddd').AndReturn(None)
 
407
        quantumclient.Client.delete_security_group('aaaa').AndReturn(None)
 
408
 
 
409
        self.m.ReplayAll()
 
410
        stack = self.create_stack(self.test_template_quantum)
 
411
 
 
412
        sg = stack['the_sg']
 
413
        self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})
 
414
 
 
415
        self.assertResourceState(sg, 'aaaa')
 
416
 
 
417
        stack.delete()
 
418
        self.m.VerifyAll()
 
419
 
 
420
    @stack_delete_after
 
421
    def test_security_group_quantum_exception(self):
 
422
        #create script
 
423
        sg_name = utils.PhysName('test_stack', 'the_sg')
 
424
        quantumclient.Client.create_security_group({
 
425
            'security_group': {
 
426
                'name': sg_name,
 
427
                'description': 'HTTP and SSH access'
 
428
            }
 
429
        }).AndReturn({
 
430
            'security_group': {
 
431
                'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
432
                'name': sg_name,
 
433
                'description': 'HTTP and SSH access',
 
434
                'security_group_rules': [],
 
435
                'id': 'aaaa'
 
436
            }
 
437
        })
 
438
 
 
439
        quantumclient.Client.create_security_group_rule({
 
440
            'security_group_rule': {
 
441
                'direction': 'ingress',
 
442
                'remote_ip_prefix': '0.0.0.0/0',
 
443
                'port_range_min': 22,
 
444
                'ethertype': 'IPv4',
 
445
                'port_range_max': 22,
 
446
                'protocol': 'tcp',
 
447
                'security_group_id': 'aaaa'
 
448
            }
 
449
        }).AndRaise(
 
450
            QuantumClientException(status_code=409))
 
451
        quantumclient.Client.create_security_group_rule({
 
452
            'security_group_rule': {
 
453
                'direction': 'ingress',
 
454
                'remote_ip_prefix': '0.0.0.0/0',
 
455
                'port_range_min': 80,
 
456
                'ethertype': 'IPv4',
 
457
                'port_range_max': 80,
 
458
                'protocol': 'tcp',
 
459
                'security_group_id': 'aaaa'
 
460
            }
 
461
        }).AndRaise(
 
462
            QuantumClientException(status_code=409))
 
463
        quantumclient.Client.create_security_group_rule({
 
464
            'security_group_rule': {
 
465
                'direction': 'egress',
 
466
                'remote_ip_prefix': '10.0.1.0/24',
 
467
                'port_range_min': 22,
 
468
                'ethertype': 'IPv4',
 
469
                'port_range_max': 22,
 
470
                'protocol': 'tcp',
 
471
                'security_group_id': 'aaaa'
 
472
            }
 
473
        }).AndRaise(
 
474
            QuantumClientException(status_code=409))
 
475
 
 
476
        # delete script
 
477
        quantumclient.Client.show_security_group('aaaa').AndReturn({
 
478
            'security_group': {
 
479
                'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
480
                'name': 'sc1',
 
481
                'description': '',
 
482
                'security_group_rules': [{
 
483
                    'direction': 'ingress',
 
484
                    'protocol': 'tcp',
 
485
                    'port_range_max': 22,
 
486
                    'id': 'bbbb',
 
487
                    'ethertype': 'IPv4',
 
488
                    'security_group_id': 'aaaa',
 
489
                    'remote_ip_prefix': '0.0.0.0/0',
 
490
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
491
                    'port_range_min': 22
 
492
                }, {
 
493
                    'direction': 'ingress',
 
494
                    'protocol': 'tcp',
 
495
                    'port_range_max': 80,
 
496
                    'id': 'cccc',
 
497
                    'ethertype': 'IPv4',
 
498
                    'security_group_id': 'aaaa',
 
499
                    'remote_ip_prefix': '0.0.0.0/0',
 
500
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
501
                    'port_range_min': 80
 
502
                }, {
 
503
                    'direction': 'egress',
 
504
                    'protocol': 'tcp',
 
505
                    'port_range_max': 22,
 
506
                    'id': 'dddd',
 
507
                    'ethertype': 'IPv4',
 
508
                    'security_group_id': 'aaaa',
 
509
                    'remote_ip_prefix': '10.0.1.0/24',
 
510
                    'tenant_id': 'f18ca530cc05425e8bac0a5ff92f7e88',
 
511
                    'port_range_min': 22
 
512
                }],
 
513
                'id': 'aaaa'}})
 
514
        quantumclient.Client.delete_security_group_rule('bbbb').AndRaise(
 
515
            QuantumClientException(status_code=404))
 
516
        quantumclient.Client.delete_security_group_rule('cccc').AndRaise(
 
517
            QuantumClientException(status_code=404))
 
518
        quantumclient.Client.delete_security_group_rule('dddd').AndRaise(
 
519
            QuantumClientException(status_code=404))
 
520
        quantumclient.Client.delete_security_group('aaaa').AndRaise(
 
521
            QuantumClientException(status_code=404))
 
522
 
 
523
        quantumclient.Client.show_security_group('aaaa').AndRaise(
 
524
            QuantumClientException(status_code=404))
 
525
 
 
526
        self.m.ReplayAll()
 
527
        stack = self.create_stack(self.test_template_quantum)
 
528
 
 
529
        sg = stack['the_sg']
 
530
        self.assertRaises(resource.UpdateReplace, sg.handle_update, {}, {}, {})
 
531
 
 
532
        self.assertResourceState(sg, 'aaaa')
 
533
 
 
534
        self.assertEqual(None, sg.delete())
 
535
 
 
536
        sg.state_set(sg.CREATE, sg.COMPLETE, 'to delete again')
 
537
        sg.resource_id = 'aaaa'
 
538
        stack.delete()
 
539
 
 
540
        self.m.VerifyAll()