'Test whether the conversion from remote torrent dict to json works'

def test_convert_torrent_to_json_dict(self):

    mocked_db = MockObject()
    mocked_db.latest_matchinfo_torrent = None
    self.session.open_dbhandler = (lambda _: mocked_db)
    input = {'torrent_id': 42, 'infohash': 'a', 'name': 'test    torrent', 'length': 43, 'category': 'other', 'num_seeders': 1, 'num_leechers': 2}
    output = {'id': 42, 'infohash': 'a'.encode('hex'), 'name': 'test    torrent', 'size': 43, 'category': 'other', 'num_seeders': 1, 'num_leechers': 2, 'last_tracker_check': 0, 'relevance_score': 0.0}
    self.assertEqual(convert_search_torrent_to_json(input), output)
    input['name'] = None
    output['name'] = 'Unnamed    torrent'
    self.assertEqual(convert_search_torrent_to_json(input), output)
    input['name'] = '         DCTB \n\n DCTB          DCTB '
    output['name'] = 'Unnamed    torrent'
    self.assertEqual(convert_search_torrent_to_json(input), output)
