def test_restore(self):
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}, 'B': {'Type': 'GenericResourceType'}}}
    self.stack = stack.Stack(self.ctx, 'stack_details_test', template.Template(tmpl))
    self.stack.store()
    self.stack.create()
    data = copy.deepcopy(self.stack.prepare_abandon())
    fake_snapshot = collections.namedtuple('Snapshot', ('data', 'stack_id'))(data, self.stack.id)
    new_tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}}}
    updated_stack = stack.Stack(self.ctx, 'updated_stack', template.Template(new_tmpl))
    self.stack.update(updated_stack)
    self.assertEqual(1, len(self.stack.resources))
    self.stack.restore(fake_snapshot)
    self.assertEqual((stack.Stack.RESTORE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual(2, len(self.stack.resources))
def test_restore(self):
    tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}, 'B': {'Type': 'GenericResourceType'}}}
    self.stack = stack.Stack(self.ctx, 'stack_details_test', template.Template(tmpl))
    self.stack.store()
    self.stack.create()
    data = copy.deepcopy(self.stack.prepare_abandon())
    fake_snapshot = collections.namedtuple('Snapshot', ('data', 'stack_id'))(data, self.stack.id)
    new_tmpl = {'HeatTemplateFormatVersion': '2012-12-12', 'Resources': {'A': {'Type': 'GenericResourceType'}}}
    updated_stack = stack.Stack(self.ctx, 'updated_stack', template.Template(new_tmpl))
    self.stack.update(updated_stack)
    self.assertEqual(1, len(self.stack.resources))
    self.stack.restore(fake_snapshot)
    self.assertEqual((stack.Stack.RESTORE, stack.Stack.COMPLETE), self.stack.state)
    self.assertEqual(2, len(self.stack.resources))