'Testing whether the right operations happen when we receive metadata'

@deferred(timeout=10)
def test_on_metadata_received_alert(self):

    test_deferred = Deferred()
    def mocked_checkpoint():
        test_deferred.callback(None)
    self.libtorrent_download_impl.handle.trackers = (lambda : [])
    self.libtorrent_download_impl.handle.save_resume_data = (lambda : None)
    torrent_dict = {'name': 'test', 'piece    length': 42, 'pieces': '', 'files': []}
    get_info_from_handle(self.libtorrent_download_impl.handle).metadata = (lambda : lt.bencode(torrent_dict))
    self.libtorrent_download_impl.checkpoint = mocked_checkpoint
    self.libtorrent_download_impl.session = MockObject()
    self.libtorrent_download_impl.session.lm = MockObject()
    self.libtorrent_download_impl.session.lm.rtorrent_handler = None
    self.libtorrent_download_impl.session.lm.torrent_db = None
    self.libtorrent_download_impl.on_metadata_received_alert(None)
    return test_deferred
