def test_resource_required_by(self):
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'AResource': {'Type': 'GenericResourceType'}, 'BResource': {'Type': 'GenericResourceType', 'DependsOn': 'AResource'}, 'CResource': {'Type': 'GenericResourceType', 'DependsOn': 'BResource'}, 'DResource': {'Type': 'GenericResourceType', 'DependsOn': 'BResource'}}}
    self.stack = stack.Stack(self.ctx, 'depends_test_stack', template.Template(tmpl))
    self.stack.store()
    self.stack.create()
    self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual(['BResource'], self.stack['AResource'].required_by())
    self.assertEqual([], self.stack['CResource'].required_by())
    required_by = self.stack['BResource'].required_by()
    self.assertEqual(2, len(required_by))
    for r in ['CResource', 'DResource']:
        self.assertIn(r, required_by)
def test_resource_required_by(self):
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'AResource': {'Type': 'GenericResourceType'}, 'BResource': {'Type': 'GenericResourceType', 'DependsOn': 'AResource'}, 'CResource': {'Type': 'GenericResourceType', 'DependsOn': 'BResource'}, 'DResource': {'Type': 'GenericResourceType', 'DependsOn': 'BResource'}}}
    self.stack = stack.Stack(self.ctx, 'depends_test_stack', template.Template(tmpl))
    self.stack.store()
    self.stack.create()
    self.assertEqual((stack.Stack.CREATE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual(['BResource'], self.stack['AResource'].required_by())
    self.assertEqual([], self.stack['CResource'].required_by())
    required_by = self.stack['BResource'].required_by()
    self.assertEqual(2, len(required_by))
    for r in ['CResource', 'DResource']:
        self.assertIn(r, required_by)