deluge/deluge/tests/test_torrentmanager.py
bendikro 260268f62b [Tests] Inherit from BaseTestCase in testcases
* Testcases in test_torrent.py and test_torrentmanager.py creates
  components and should therefore inherit from BaseTestCase.
* Cleanup in test_json_api.py
2016-05-24 21:10:52 +02:00

42 lines
1.2 KiB
Python

import base64
import os
import warnings
from twisted.internet import defer
from deluge import component
from deluge.core.core import Core
from deluge.core.rpcserver import RPCServer
from deluge.error import InvalidTorrentError
from . import common
from .basetest import BaseTestCase
warnings.filterwarnings("ignore", category=RuntimeWarning)
warnings.resetwarnings()
class TorrentmanagerTestCase(BaseTestCase):
def set_up(self):
common.set_tmp_config_dir()
RPCServer(listen=False)
self.core = Core()
return component.start()
def tear_down(self):
return component.shutdown()
@defer.inlineCallbacks
def test_remove_torrent(self):
filename = os.path.join(os.path.dirname(__file__), "test.torrent")
torrent_id = yield self.core.add_torrent_file(filename, base64.encodestring(open(filename).read()), {})
self.assertTrue(self.core.torrentmanager.remove(torrent_id, False))
def test_remove_torrent_false(self):
"""Test when remove_torrent returns False"""
raise unittest.SkipTest("")
def test_remove_invalid_torrent(self):
self.assertRaises(InvalidTorrentError, self.core.torrentmanager.remove, "torrentidthatdoesntexist")