'Verify the cron job inserts the right rows.'

@patch.object(googleanalytics, 'search_ctr')
def test_update_search_ctr(self, search_ctr):

    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)
