add start/stop/check torrent daemon

This commit is contained in:
stubbfel
2014-09-23 23:25:25 +02:00
parent 74bd0f0220
commit 912d3962a2
5 changed files with 165 additions and 94 deletions

View File

@@ -7,7 +7,7 @@ import urllib
import os
from config.config import Config
import shutil
import utilities.file_methods as fm
import subprocess
class TestTorrentCliEntryHandler(unittest.TestCase):
@@ -45,7 +45,9 @@ class TestTorrentCliEntryHandler(unittest.TestCase):
self.assertTrue(os.path.exists(TorrentCliEntryHandler.SettingFile))
def test_start_torrent(self):
self.__tceh.start_torrent("/home/dev/projects/feedcrawler/testenv/testfeeds/podcast/SBK028_Arbeit.mp3.torrent", "testtorrents/", "testtorrents/")
tc = self.__tceh.start_torrent("/home/dev/projects/feedcrawler/testenv/testfeeds/podcast/SBK028_Arbeit.mp3.torrent", "testtorrents/", "testtorrents/")
self.assertTrue(isinstance(tc, subprocess.Popen))
tc.terminate()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,36 @@
__author__ = 'dev'
import unittest
from feed.feed import Feed
from feed.torrent_daemon_entry_handler import TorrentDaemonEntryHandler
class TestTorrentDaemonEntryHandler(unittest.TestCase):
def setUp(self):
self.__feed = Feed("sbk", "podcast", "application/x-bittorrent", "testfeeds/podcast/sbk/sbk.xml")
self.__test_torrent = "http://bitlove.org/nitramred/staatsbuergerkunde-mp3/SBK028_Arbeit.mp3.torrent"
self.__tdeh = TorrentDaemonEntryHandler(self.__feed)
self.__tdeh.start_daemon()
def tearDown(self):
self.__tdeh.stop_daemon()
def test_start_daemon(self):
self.assertTrue(self.__tdeh.is_running_daemon())
def test_stop_daemon(self):
self.__tdeh.stop_daemon()
self.assertFalse(self.__tdeh.is_running_daemon())
def test_is_running_daemon(self):
self.assertTrue(self.__tdeh.is_running_daemon())
self.__tdeh.stop_daemon()
self.assertFalse(self.__tdeh.is_running_daemon())
def test_start_torrent(self):
self.assertTrue(False)
def test_add_torrent_to_daemon(self):
self.assertTrue(False)
if __name__ == '__main__':
unittest.main()