示例#1
0
文件: tests.py 项目: Gr1N/rpihelper
    def test_transmission_error(self):
        tc = MagicMock()
        tc_add_torrent = raise_exception
        tc.add_torrent = tc_add_torrent

        success = transmissionrpc_add_torrent(tc, 'fake_file')
        self.assertFalse(success)
示例#2
0
文件: tests.py 项目: Gr1N/rpihelper
    def test_ok(self):
        tc = MagicMock()
        tc_add_torrent = MagicMock()
        tc.add_torrent = tc_add_torrent

        success = transmissionrpc_add_torrent(tc, 'fake_file')
        tc_add_torrent.assert_called_once()
        self.assertTrue(success)
示例#3
0
文件: tasks.py 项目: Gr1N/rpihelper
def check_torrent_files():
    tc = transmissionrpc_client()
    if not tc:
        current_app.logger.info('No connetion to remote transmission, stop task.')
        return

    dbc = DropBoxClient()
    for f in dbc.folder(current_app.config['TRANSMISSION_DROPBOX_TORRENTS_FOLDER']):
        with NamedTemporaryFile() as tf:
            tf.write(dbc.file(f))
            success = transmissionrpc_add_torrent(tc, 'file://%s' % tf.name)

        if success:
            dbc.rm_file(f)
            current_app.logger.info('Successfully added torrent "%s".' % f)
        else:
            current_app.logger.info('Torrent "%s" not added, skip it.' % f)