'Ensure that requires are computed correctly.
Ensure that requires are computed correctly even if resource
create fails.'

def test_create_convergence_sets_requires_for_failure(self):

    tmpl = rsrc_defn.ResourceDefinition('test_res', 'Foo')
    res = generic_rsrc.GenericResource('test_res', tmpl, self.stack)
    res.store()
    dummy_ex = exception.ResourceNotAvailable(resource_name=res.name)
    res.create = mock.Mock(side_effect=dummy_ex)
    self._assert_resource_lock(res.id, None, None)
    res_data = {(1, True): {u'id': 5, u'name': 'A', 'attrs': {}}, (2, True): {u'id': 3, u'name': 'B', 'attrs': {}}}
    res_data = node_data.load_resources_data(res_data)
    self.assertRaises(exception.ResourceNotAvailable, res.create_convergence, self.stack.t.id, res_data, 'engine-007', self.dummy_timeout, self.dummy_event)
    self.assertItemsEqual([5, 3], res.requires)
    self._assert_resource_lock(res.id, None, None)
