'Testing whether the right operations are performed when we get a torrent finished alert'

def test_download_finish_alert(self):

    status = self.libtorrent_download_impl.handle.status()
    status.paused = False
    status.state = DLSTATUS_DOWNLOADING
    status.progress = 0.9
    status.error = None
    status.total_wanted = 33
    status.download_payload_rate = 928
    status.upload_payload_rate = 928
    status.all_time_upload = 42
    status.all_time_download = 43
    status.finished_time = 1234
    def map_file(_dummy1, start_byte, _dummy2):
        res = MockObject()
        res.piece = int((start_byte / 250))
        return res
    self.libtorrent_download_impl.handle.get_torrent_info().num_pieces = (lambda : 4)
    self.libtorrent_download_impl.handle.get_torrent_info().map_file = map_file
    self.libtorrent_download_impl.handle.piece_priorities = (lambda : [0, 0, 0, 0])
    self.libtorrent_download_impl.set_vod_mode(True)
    self.libtorrent_download_impl.set_mode(DLMODE_VOD)
    self.libtorrent_download_impl.on_torrent_finished_alert(None)
    has_priorities_task = False
    for task_name in self.libtorrent_download_impl._pending_tasks.iterkeys():
        if ('reset_priorities' in task_name):
            has_priorities_task = True
    self.assertTrue(has_priorities_task)
