当前位置: 首页>>代码示例>>Python>>正文


Python RTorrent.load方法代码示例

本文整理汇总了Python中flexget.plugins.plugin_rtorrent.RTorrent.load方法的典型用法代码示例。如果您正苦于以下问题:Python RTorrent.load方法的具体用法?Python RTorrent.load怎么用?Python RTorrent.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flexget.plugins.plugin_rtorrent.RTorrent的用法示例。


在下文中一共展示了RTorrent.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_load

# 需要导入模块: from flexget.plugins.plugin_rtorrent import RTorrent [as 别名]
# 或者: from flexget.plugins.plugin_rtorrent.RTorrent import load [as 别名]
    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
开发者ID:Farbdose,项目名称:Flexget,代码行数:36,代码来源:test_rtorrent.py

示例2: test_load

# 需要导入模块: from flexget.plugins.plugin_rtorrent import RTorrent [as 别名]
# 或者: from flexget.plugins.plugin_rtorrent.RTorrent import load [as 别名]
    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': 'test_custom1'},
            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
        match_binary = Matcher(compare_binary, xmlrpclib.Binary(torrent_raw))
        mocked_proxy.load.raw_start.assert_called_with(
            '',
            match_binary,
            'd.priority.set=3',
            'd.directory.set=\\/data\\/downloads',
            'd.custom1.set=test\\_custom1'
        )
开发者ID:Ekhozie,项目名称:Flexget,代码行数:30,代码来源:test_rtorrent.py


注:本文中的flexget.plugins.plugin_rtorrent.RTorrent.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。