'If a user deploys an app with a config value set for HEALTHCHECK_URL, the controller
should check that the application responds with a 200 OK. If it\'s down, the app should be
rolled back.'

@mock.patch(u'requests.get', mock_status_not_found)
@mock.patch(u'api.models.get_etcd_client', (lambda func: func))
@mock.patch(u'time.sleep', (lambda func: func))
@mock.patch(u'api.models.logger')
def test_app_healthcheck_bad(self, mock_logger):

    response = self._test_app_healthcheck()
    self.assertEqual(response.status_code, 503)
    self.assertEqual(response.data, {u'detail': u'aborting,    app    containers    failed    to    respond    to    health    check'})
    self.assertEqual(self.app.release_set.latest().version, 2)
    exp_msg = u"{}:    app    failed    health    check    (got    '404',    expected:    '200');    trying    again    in    0.0    seconds".format(self.app.id)
    exp_log_call = mock.call(logging.WARNING, exp_msg)
    log_calls = mock_logger.log.mock_calls
    self.assertEqual(log_calls.count(exp_log_call), 3)
    exp_msg = u"{}:    app    failed    health    check    (got    '404',    expected:    '200')".format(self.app.id)
    exp_log_call = mock.call(logging.WARNING, exp_msg)
    self.assertEqual(log_calls.count(exp_log_call), 1)
