'Test filtering results by product.'

def test_product_filter(self):

    today = date.today()
    p1 = ProductFactory()
    p2 = ProductFactory()
    for i in range(3):
        for p in [p1, p2]:
            WikiMetricFactory(date=(today - timedelta(days=i)), product=p)
    WikiMetricFactory(date=(today - timedelta(days=4)), product=p2)
    response = self.client.get(urlparams(reverse('api.wikimetric_list'), format='json', product=p1.slug))
    eq_(200, response.status_code)
    results = json.loads(response.content)['results']
    eq_(3, len(results))
    response = self.client.get(urlparams(reverse('api.wikimetric_list'), format='json', product=p2.slug))
    eq_(200, response.status_code)
    results = json.loads(response.content)['results']
    eq_(4, len(results))
