def test_torrents(self, mocked_proxy): mocked_proxy = mocked_proxy() hash1 = '09977FE761AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' hash2 = '09977FE761BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB' mocked_proxy.d.multicall.return_value = ( ['/data/downloads', 'private.torrent', hash1, 'test_custom1'], ['/data/downloads', 'private.torrent', hash2, 'test_custom2'], ) client = RTorrent('http://localhost/RPC2') torrents = client.torrents(fields=['custom1']) # Required fields should be added assert isinstance(torrents, list) for torrent in torrents: assert torrent.get('base_path') == '/data/downloads' assert torrent.get('name') == 'private.torrent' if torrent.get('hash') == hash1: assert torrent.get('custom1') == 'test_custom1' elif torrent.get('hash') == hash2: assert torrent.get('custom1') == 'test_custom2' else: assert False, 'Invalid hash returned' assert mocked_proxy.system.multicall.called_with(( ['main', 'd.directory_base=', 'd.name=', 'd.hash=', u'd.custom1='], ))