'Verify the metrics inserted by process_exit_surveys cron job.'

@patch.object(surveygizmo_utils, 'requests')
def test_process_exit_surveys(self, requests):

    requests.get.return_value.content = SURVEY_GIZMO_EXIT_SURVEY_RESPONSE
    yes_kind = MetricKindFactory(code=EXIT_SURVEY_YES_CODE)
    no_kind = MetricKindFactory(code=EXIT_SURVEY_NO_CODE)
    dunno_kind = MetricKindFactory(code=EXIT_SURVEY_DONT_KNOW_CODE)
    two_days_back = (date.today() - timedelta(days=2))
    MetricFactory(kind=yes_kind, start=two_days_back)
    with self.settings(SURVEYGIZMO_API_TOKEN='test', SURVEYGIZMO_API_TOKEN_SECRET='test'):
        _process_exit_survey_results()
    eq_(4, Metric.objects.count())
    eq_(2, Metric.objects.filter(kind=yes_kind)[1].value)
    eq_(1, Metric.objects.get(kind=no_kind).value)
    eq_(1, Metric.objects.get(kind=dunno_kind).value)
