Exemple #1
0
    def test_calls_create_chunked_tasks_signatures(self, get_mock, create_chunked_mock):
        create_chunked_mock.return_value = group([])
        addon = addon_factory(weekly_downloads=0)
        count = 56789
        langpack = addon_factory(type=amo.ADDON_LPAPP, weekly_downloads=0)
        langpack_count = 12345
        dictionary = addon_factory(type=amo.ADDON_DICT, weekly_downloads=0)
        dictionary_count = 6789
        addon_without_count = addon_factory(type=amo.ADDON_DICT, weekly_downloads=2)
        # This one should be ignored.
        addon_factory(guid=None, type=amo.ADDON_LPAPP)
        # This one should be ignored as well.
        addon_factory(guid='', type=amo.ADDON_LPAPP)
        get_mock.return_value = [
            (addon.addonguid.hashed_guid, count),
            (langpack.addonguid.hashed_guid, langpack_count),
            (dictionary.addonguid.hashed_guid, dictionary_count),
        ]

        chunk_size = 123
        cron.update_addon_weekly_downloads(chunk_size)

        create_chunked_mock.assert_called_with(
            update_addon_weekly_downloads,
            [
                (addon_without_count.addonguid.hashed_guid, 0),
                (addon.addonguid.hashed_guid, count),
                (langpack.addonguid.hashed_guid, langpack_count),
                (dictionary.addonguid.hashed_guid, dictionary_count),
            ],
            chunk_size,
        )
Exemple #2
0
    def test_update_weekly_downloads(self, get_mock):
        addon = addon_factory(weekly_downloads=0)
        count = 56789
        get_mock.return_value = [(addon.addonguid.hashed_guid, count)]

        cron.update_addon_weekly_downloads()
        addon.refresh_from_db()

        assert addon.weekly_downloads == count