

@patch.object(googleanalytics, 'search_ctr')
def test_update_search_ctr(self, search_ctr):
    'Verify the cron job inserts the right rows.'
    clicks_kind = MetricKindFactory(code=SEARCH_CLICKS_METRIC_CODE)
    MetricKindFactory(code=SEARCH_SEARCHES_METRIC_CODE)
    search_ctr.return_value = {
        '2013-06-06': 42.123456789,
        '2013-06-07': 13.7654321,
        '2013-06-08': 99.55555,
    }
    update_search_ctr_metric()
    metrics = Metric.objects.filter(kind=clicks_kind).order_by('start')
    eq_(3, len(metrics))
    eq_(421, metrics[0].value)
    eq_(138, metrics[1].value)
    eq_(date(2013, 6, 8), metrics[2].start)

dataset/ETHPy150Open mozilla/kitsune/kitsune/kpi/tests/test_cron.py CronJobTests.test_update_search_ctr/original