def test_check_fail(self):
    stk = self._get_stack_to_check('check-fail')
    stk.check()
    self.assertEqual(stk.FAILED, stk.status)
    self.assertEqual(stk.CHECK, stk.action)
    self.assertFalse(stk['A'].handle_check.called)
    self.assertFalse(stk['B'].handle_check.called)
    self.assertIn('Resource A not created yet', stk.status_reason)
    self.assertIn('Resource B not created yet', stk.status_reason)
    stk['A'].handle_check.side_effect = Exception('fail-A')
    stk['B'].handle_check.side_effect = Exception('fail-B')
    stk['A'].state_set(stk['A'].CREATE, stk['A'].COMPLETE)
    stk['B'].state_set(stk['B'].CREATE, stk['B'].COMPLETE)
    stk.check()
    self.assertEqual(stk.FAILED, stk.status)
    self.assertEqual(stk.CHECK, stk.action)
    self.assertTrue(stk['A'].handle_check.called)
    self.assertTrue(stk['B'].handle_check.called)
    self.assertIn('fail-A', stk.status_reason)
    self.assertIn('fail-B', stk.status_reason)
def test_check_fail(self):
    stk = self._get_stack_to_check('check-fail')
    stk.check()
    self.assertEqual(stk.FAILED, stk.status)
    self.assertEqual(stk.CHECK, stk.action)
    self.assertFalse(stk['A'].handle_check.called)
    self.assertFalse(stk['B'].handle_check.called)
    self.assertIn('Resource A not created yet', stk.status_reason)
    self.assertIn('Resource B not created yet', stk.status_reason)
    stk['A'].handle_check.side_effect = Exception('fail-A')
    stk['B'].handle_check.side_effect = Exception('fail-B')
    stk['A'].state_set(stk['A'].CREATE, stk['A'].COMPLETE)
    stk['B'].state_set(stk['B'].CREATE, stk['B'].COMPLETE)
    stk.check()
    self.assertEqual(stk.FAILED, stk.status)
    self.assertEqual(stk.CHECK, stk.action)
    self.assertTrue(stk['A'].handle_check.called)
    self.assertTrue(stk['B'].handle_check.called)
    self.assertIn('fail-A', stk.status_reason)
    self.assertIn('fail-B', stk.status_reason)