def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

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

        resp = client.load(
            torrent_raw,
            fields={'priority': 3, 'directory': '/data/downloads', 'custom1': 'testing'},
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with('', 'mkdir', '-p', '/data/downloads')

        # Ensure load was called
        assert mocked_proxy.load.raw_start.called

        match_binary = Matcher(compare_binary, xmlrpc_client.Binary(torrent_raw))

        called_args = mocked_proxy.load.raw_start.call_args_list[0][0]
        assert len(called_args) == 5
        assert '' == called_args[0]
        assert match_binary in called_args

        fields = [p for p in called_args[2:]]
        assert len(fields) == 3
        assert 'd.directory.set=\\/data\\/downloads' in fields
        assert 'd.custom1.set=testing' in fields
        assert 'd.priority.set=3' in fields
Beispiel #2
0
    def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

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

        resp = client.load(
            torrent_raw,
            fields={'priority': 3, 'directory': '/data/downloads', 'custom1': 'testing'},
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with('', 'mkdir', '-p', '/data/downloads')

        # Ensure load was called
        assert mocked_proxy.load.raw_start.called

        match_binary = Matcher(compare_binary, xmlrpc_client.Binary(torrent_raw))

        called_args = mocked_proxy.load.raw_start.call_args_list[0][0]
        assert len(called_args) == 5
        assert '' == called_args[0]
        assert match_binary in called_args

        fields = [p for p in called_args[2:]]
        assert len(fields) == 3
        assert 'd.directory.set=\\/data\\/downloads' in fields
        assert 'd.custom1.set=testing' in fields
        assert 'd.priority.set=3' in fields
Beispiel #3
0
    def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

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

        resp = client.load(
            torrent_raw,
            fields={"priority": 3, "directory": "/data/downloads", "custom1": "testing"},
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with("", "mkdir", "-p", "/data/downloads")

        # Ensure load was called
        assert mocked_proxy.load.raw_start.called

        match_binary = Matcher(compare_binary, xmlrpc_client.Binary(torrent_raw))

        called_args = mocked_proxy.load.raw_start.call_args_list[0][0]
        assert len(called_args) == 5
        assert "" == called_args[0]
        assert match_binary in called_args

        fields = [p for p in called_args[2:]]
        assert len(fields) == 3
        assert "d.directory.set=\\/data\\/downloads" in fields
        assert "d.custom1.set=testing" in fields
        assert "d.priority.set=3" in fields
Beispiel #4
0
    def test_load(self, mocked_proxy):
        mocked_proxy = mocked_proxy()
        mocked_proxy.execute.throw.return_value = 0
        mocked_proxy.load.raw_start.return_value = 0

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

        resp = client.load(
            torrent_raw,
            fields={
                'priority': 3,
                'directory': '/data/downloads',
                'custom1': 'testing'
            },
            start=True,
            mkdir=True,
        )

        assert resp == 0

        # Ensure mkdir was called
        mocked_proxy.execute.throw.assert_called_with('', 'mkdir', '-p',
                                                      '/data/downloads')

        # Ensure load was called
        assert mocked_proxy.load.raw_start.called

        match_binary = Matcher(compare_binary,
                               xmlrpc_client.Binary(torrent_raw))

        called_args = mocked_proxy.load.raw_start.call_args_list[0][0]
        assert len(called_args) == 5
        assert '' == called_args[0]
        assert match_binary in called_args

        fields = [p for p in called_args[2:]]
        assert len(fields) == 3
        # TODO: check the note in clients/rtorrent.py about this escaping.
        # The client should be fixed to work consistenly on all python versions
        # Calling re.escape here is a workaround so test works on python 3.7 and older versions
        assert ('d.directory.set=' + re.escape('/data/downloads')) in fields
        assert 'd.custom1.set=testing' in fields
        assert 'd.priority.set=3' in fields