add transmission hanler
This commit is contained in:
51
testenv/tests/feed/test_torrent_cli_entry_handler.py
Normal file
51
testenv/tests/feed/test_torrent_cli_entry_handler.py
Normal file
@@ -0,0 +1,51 @@
|
||||
__author__ = 'dev'
|
||||
|
||||
import unittest
|
||||
from feed.torrent_cli_entry_handler import TorrentCliEntryHandler
|
||||
from feed.feed import Feed
|
||||
import urllib
|
||||
import os
|
||||
from config.config import Config
|
||||
import shutil
|
||||
import utilities.file_methods as fm
|
||||
|
||||
|
||||
class TestTorrentCliEntryHandler(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.__test_torrent2 = "testfeeds/podcast/SBK028_Arbeit.mp3.torrent"
|
||||
self.__test_torrent3 = "http://bitlove.org/nitramred/staatsbuergerkunde-mp3/SBK028_Arbeit.mp3.torren"
|
||||
self.__test_torrent4 = "testfeeds/podcast/SBK028_Arbeit.mp3.trrent"
|
||||
self.__torrent_file = "/home/dev/projects/feedcrawler/testenv/testtorrents/SBK028_Arbeit.mp3.torrent"
|
||||
self.__torrent_folder = Config["TorrentStorageFolder"]
|
||||
self.__tceh = TorrentCliEntryHandler(self.__feed)
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(self.__torrent_file):
|
||||
os.remove(self.__torrent_file)
|
||||
if os.path.exists(self.__torrent_folder):
|
||||
shutil.rmtree(self.__torrent_folder)
|
||||
|
||||
def test_download_torrent(self):
|
||||
self.__tceh.download_torrent(self.__test_torrent)
|
||||
self.assertTrue(os.path.exists(self.__torrent_file))
|
||||
os.remove(self.__torrent_file)
|
||||
self.__tceh.download_torrent(self.__test_torrent2)
|
||||
self.assertTrue(os.path.exists(self.__torrent_file))
|
||||
|
||||
def test_download_torrent_wrong_url(self):
|
||||
self.assertRaises(urllib.error.HTTPError, self.__tceh.download_torrent,self.__test_torrent3)
|
||||
self.assertRaises(ValueError, self.__tceh.download_torrent, self.__test_torrent4)
|
||||
|
||||
def test_init_torrent_folder(self):
|
||||
self.__tceh.init_torrent_folder(self.__torrent_folder)
|
||||
self.assertTrue(os.path.exists(self.__torrent_folder))
|
||||
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/")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user