@patch.object(surveygizmo_utils, 'requests')
    def test_process_exit_surveys(self, requests):
        """Verify the metrics inserted by process_exit_surveys cron job."""
        requests.get.return_value.content = SURVEY_GIZMO_EXIT_SURVEY_RESPONSE

        # Create the kinds.
        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)

        # Add a metric for 2 days ago so only 1 new day is collected.
        MetricFactory(kind=yes_kind, start=two_days_back)

        # Collect and process.
        with self.settings(SURVEYGIZMO_API_TOKEN='test',
                           SURVEYGIZMO_API_TOKEN_SECRET='test'):
            _process_exit_survey_results()

        # Verify.
        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)
dataset/ETHPy150Open mozilla/kitsune/kitsune/kpi/tests/test_cron.py/CronJobTests.test_process_exit_surveys/original