def test_addons_collections(self):
        collection2 = Collection.objects.create(name="collection2")
        CollectionAddon.objects.create(addon_id=3615, collection=collection2)
        vals = [(3, datetime.date(2013, 1, 1)), (5, datetime.date(2013, 1, 2)), (7, datetime.date(2013, 1, 3))]
        for col_id in (80, collection2.pk):
            for dls, dt in vals:
                AddonCollectionCount.objects.create(addon_id=3615, collection_id=col_id, count=dls, date=dt)

        with self.assertNumQueries(3):
            cron.update_addons_collections_downloads()
        eq_(CollectionAddon.objects.get(addon_id=3615, collection_id=80).downloads, 15)
示例#2
0
    def test_addons_collections(self):
        collection2 = Collection.objects.create(name="collection2")
        CollectionAddon.objects.create(addon_id=3615, collection=collection2)
        vals = [(3, datetime.date(2013, 1, 1)),
                (5, datetime.date(2013, 1, 2)),
                (7, datetime.date(2013, 1, 3))]
        for col_id in (80, collection2.pk):
            for dls, dt in vals:
                AddonCollectionCount.objects.create(
                    addon_id=3615, collection_id=col_id,
                    count=dls, date=dt)

        with self.assertNumQueries(3):
            cron.update_addons_collections_downloads()
        assert CollectionAddon.objects.get(
            addon_id=3615, collection_id=80).downloads == 15