Skip to content

Commit

Permalink
add: simple full pp test and needed changes to test_lib and refactori…
Browse files Browse the repository at this point in the history
…ng of a fake/dummy function
  • Loading branch information
lad1337 committed Apr 20, 2012
1 parent b8d1825 commit 704b216
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
17 changes: 12 additions & 5 deletions tests/pp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,20 @@ def test__find_ep_destination_folder(self):


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__':
Expand Down
6 changes: 0 additions & 6 deletions tests/snatch_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []


Expand Down
19 changes: 19 additions & 0 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
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')

Expand Down Expand Up @@ -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
Expand All @@ -105,11 +113,13 @@ def setUp(self):
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):
Expand Down Expand Up @@ -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__':
Expand Down

0 comments on commit 704b216

Please sign in to comment.