'Test elastic clickthrough read API.'

def test_elastic_clickthrough_get(self):

    (click_kind, search_kind) = self._make_elastic_metric_kinds()
    MetricFactory(kind=click_kind, start=date(2000, 1, 1), value=1)
    MetricFactory(kind=search_kind, start=date(2000, 1, 1), value=10)
    MetricFactory(kind=click_kind, start=date(2000, 1, 9), value=2)
    MetricFactory(kind=search_kind, start=date(2000, 1, 9), value=20)
    url = reverse('api.kpi.search-ctr')
    response = self.client.get((url + '?format=json'))
    data = json.loads(response.content)
    eq_(data['objects'], [{'clicks': 2, 'searches': 20, 'start': u'2000-01-09'}, {'clicks': 1, 'searches': 10, 'start': u'2000-01-01'}])
    response = self.client.get((url + '?format=json&min_start=2000-01-09'))
    data = json.loads(response.content)
    eq_(data['objects'], [{u'searches': 20, u'start': u'2000-01-09', u'clicks': 2}])
