Exemple #1
0
    def test_torrent(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.system.multicall.return_value = [['/data/downloads'],
                                                      ['private.torrent'],
                                                      [torrent_info_hash],
                                                      ['test_custom1'],
                                                      [123456]]

        client = RTorrent('http://localhost/RPC2')

        torrent = client.torrent(torrent_info_hash,
                                 fields=['custom1', 'down_rate'
                                         ])  # Required fields should be added

        assert isinstance(torrent, dict)
        assert torrent.get('base_path') == '/data/downloads'
        assert torrent.get('hash') == torrent_info_hash
        assert torrent.get('custom1') == 'test_custom1'
        assert torrent.get('name') == 'private.torrent'
        assert torrent.get('down_rate') == 123456

        assert mocked_proxy.system.multicall.called_with(([
            {
                'params': (torrent_info_hash, ),
                'methodName': 'd.base_path'
            },
            {
                'params': (torrent_info_hash, ),
                'methodName': 'd.name'
            },
            {
                'params': (torrent_info_hash, ),
                'methodName': 'd.hash'
            },
            {
                'params': (torrent_info_hash, ),
                'methodName': 'd.custom1'
            },
            {
                'params': (torrent_info_hash, ),
                'methodName': 'd.down.rate'
            },
        ]))
Exemple #2
0
    def test_torrent(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.system.multicall.return_value = [
            ['/data/downloads'], ['private.torrent'], [torrent_info_hash], ['test_custom1'], [123456]
        ]

        client = RTorrent('http://localhost/RPC2')

        torrent = client.torrent(torrent_info_hash, fields=['custom1', 'down_rate'])  # Required fields should be added

        assert isinstance(torrent, dict)
        assert torrent.get('base_path') == '/data/downloads'
        assert torrent.get('hash') == torrent_info_hash
        assert torrent.get('custom1') == 'test_custom1'
        assert torrent.get('name') == 'private.torrent'
        assert torrent.get('down_rate') == 123456

        assert mocked_proxy.system.multicall.called_with(([
            {'params': (torrent_info_hash,), 'methodName': 'd.base_path'},
            {'params': (torrent_info_hash,), 'methodName': 'd.name'},
            {'params': (torrent_info_hash,), 'methodName': 'd.hash'},
            {'params': (torrent_info_hash,), 'methodName': 'd.custom1'},
            {'params': (torrent_info_hash,), 'methodName': 'd.down.rate'},
        ]))