From 704b216b2616a8efa3d6020b01e93e1878ec5df7 Mon Sep 17 00:00:00 2001
From: Dennis Lutter <lad1337@gmail.com>
Date: Fri, 20 Apr 2012 17:02:01 +0200
Subject: [PATCH] add: simple full pp test and needed changes to test_lib and
 refactoring of a fake/dummy function

---
 tests/pp_tests.py     | 17 ++++++++++++-----
 tests/snatch_tests.py |  6 ------
 tests/test_lib.py     | 19 +++++++++++++++++++
 3 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/tests/pp_tests.py b/tests/pp_tests.py
index 78df8e613..2360ea9de 100644
--- a/tests/pp_tests.py
+++ b/tests/pp_tests.py
@@ -80,13 +80,20 @@ class PPPrivateTests(test.SickbeardTestDBCase):
 
 
 class PPBasicTests(test.SickbeardTestDBCase):
-    def setUp(self):
-        super(PPBasicTests, self).setUp()
-        self.pp = PostProcessor(test.FILEPATH)
 
-    @unittest.skip("this test is not fully configured / implmented")
     def test_process(self):
-        self.assertTrue(self.pp.process())
+        show = TVShow(3)
+        show.name = test.SHOWNAME
+        show.location = test.SHOWDIR
+        show.saveToDB()
+
+        sickbeard.showList = [show]
+        ep = TVEpisode(show, test.SEASON, test.EPISODE)
+        ep.name = "some ep name"
+        ep.saveToDB()
+
+        pp = PostProcessor(test.FILEPATH)
+        self.assertTrue(pp.process())
 
 
 if __name__ == '__main__':
diff --git a/tests/snatch_tests.py b/tests/snatch_tests.py
index 6ca7df928..5ae0ea329 100644
--- a/tests/snatch_tests.py
+++ b/tests/snatch_tests.py
@@ -44,12 +44,6 @@ def _create_fake_xml(items):
     return xml
 
 
-# the real one tries to contact tvdb just stop it from getting more info on the ep
-def _fake_specifyEP(self, season, episode):
-    pass
-
-TVEpisode.specifyEpisode = _fake_specifyEP
-
 searchItems = []
 
 
diff --git a/tests/test_lib.py b/tests/test_lib.py
index 3bc81216f..b004146ea 100644
--- a/tests/test_lib.py
+++ b/tests/test_lib.py
@@ -47,6 +47,8 @@ FILENAME = u"show name - s0" + str(SEASON) + "e0" + str(EPISODE) + ".mkv"
 FILEDIR = os.path.join(TESTDIR, SHOWNAME)
 FILEPATH = os.path.join(FILEDIR, FILENAME)
 
+SHOWDIR = os.path.join(TESTDIR, SHOWNAME+" final")
+
 #sickbeard.logger.sb_log_instance = sickbeard.logger.SBRotatingLogHandler(os.path.join(TESTDIR, 'sickbeard.log'), sickbeard.logger.NUM_LOGS, sickbeard.logger.LOG_SIZE)
 sickbeard.logger.SBRotatingLogHandler.log_file = os.path.join(os.path.join(TESTDIR, 'Logs'), 'test_sickbeard.log')
 
@@ -96,6 +98,12 @@ def _dummy_saveConfig():
 # this might be considered a hack
 mainDB.sickbeard.save_config = _dummy_saveConfig
 
+# the real one tries to contact tvdb just stop it from getting more info on the ep
+def _fake_specifyEP(self, season, episode):
+    pass
+
+sickbeard.tv.TVEpisode.specifyEpisode = _fake_specifyEP
+
 
 #=================
 # test classes
@@ -105,11 +113,13 @@ class SickbeardTestDBCase(unittest.TestCase):
         sickbeard.showList = []
         setUp_test_db()
         setUp_test_episode_file()
+        setUp_test_show_dir()
 
     def tearDown(self):
         sickbeard.showList = []
         tearDown_test_db()
         tearDown_test_episode_file()
+        tearDown_test_show_dir()
 
 
 class TestDBConnection(db.DBConnection, object):
@@ -185,6 +195,15 @@ def setUp_test_episode_file():
 def tearDown_test_episode_file():
     shutil.rmtree(FILEDIR)
 
+
+def setUp_test_show_dir():
+    if not os.path.exists(SHOWDIR):
+        os.makedirs(SHOWDIR)
+
+
+def tearDown_test_show_dir():
+    shutil.rmtree(SHOWDIR)
+
 tearDown_test_db()
 
 if __name__ == '__main__':
-- 
GitLab