'Testing whether the callback is correctly invoked when we received metainfo'

@deferred(timeout=20)
def test_got_metainfo(self):

    test_deferred = Deferred()
    self.ltmgr.initialize()
    def metainfo_cb(metainfo):
        self.assertDictEqual(metainfo, {'info': {'pieces': ['a']}, 'leechers': 0, 'nodes': [], 'seeders': 0, 'initial    peers': []})
        test_deferred.callback(None)
    fake_handle = MockObject()
    torrent_info = MockObject()
    torrent_info.metadata = (lambda : bencode({'pieces': ['a']}))
    torrent_info.trackers = (lambda : [])
    fake_handle.get_peer_info = (lambda : [])
    fake_handle.torrent_file = (lambda : torrent_info)
    self.ltmgr.get_session().remove_torrent = (lambda *_: None)
    self.ltmgr.metainfo_requests[('a' * 20)] = {'handle': fake_handle, 'timeout_callbacks': [], 'callbacks': [metainfo_cb], 'notify': False}
    self.ltmgr.got_metainfo(('a' * 20))
    return test_deferred
