Private GIT

Skip to content
Snippets Groups Projects
Commit 0eaa5993 authored by labrys's avatar labrys
Browse files

Lint 10/10

parent c11c6d0a
No related branches found
No related tags found
No related merge requests found
...@@ -20,16 +20,23 @@ ...@@ -20,16 +20,23 @@
### ###
# As a test case, there are instances in which it is necessary to call protected members of # As a test case, there are instances in which it is necessary to call protected members of
# classes in order to test those classes. Therefore: # classes in order to test those classes. Therefore we will be pylint disable protected-access
# pylint: disable=W0212
### ###
import sys, os.path # pylint: disable=line-too-long
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib')))
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) """
Test notifiers
"""
import sys
import os.path
import unittest import unittest
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib')))
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import tests.test_lib as test import tests.test_lib as test
from sickbeard import db from sickbeard import db
...@@ -40,8 +47,11 @@ from sickbeard.notifiers.prowl import ProwlNotifier ...@@ -40,8 +47,11 @@ from sickbeard.notifiers.prowl import ProwlNotifier
from sickrage.helper.encoding import ss from sickrage.helper.encoding import ss
class NotifierTests(test.SickbeardTestDBCase):
class NotifierTests(test.SickbeardTestDBCase): # pylint: disable=too-many-public-methods
"""
Test notifiers
"""
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
num_legacy_shows = 3 num_legacy_shows = 3
...@@ -81,12 +91,22 @@ class NotifierTests(test.SickbeardTestDBCase): ...@@ -81,12 +91,22 @@ class NotifierTests(test.SickbeardTestDBCase):
cls.shows.append(show) cls.shows.append(show)
def setUp(self): def setUp(self):
"""
Set up tests
"""
self._debug_spew("\n\r") self._debug_spew("\n\r")
#def test_boxcar(self): @unittest.skip('Not yet implemented')
# pass def test_boxcar(self):
"""
Test boxcar notifications
"""
pass
def test_email(self): def test_email(self):
"""
Test email notifications
"""
email_notifier = EmailNotifier() email_notifier = EmailNotifier()
# Per-show-email notifications were added early on and utilized a different format than the other notifiers. # Per-show-email notifications were added early on and utilized a different format than the other notifiers.
...@@ -103,14 +123,13 @@ class NotifierTests(test.SickbeardTestDBCase): ...@@ -103,14 +123,13 @@ class NotifierTests(test.SickbeardTestDBCase):
showid = self._get_showid_by_showname(show.name) showid = self._get_showid_by_showname(show.name)
Home.saveShowNotifyList(show=showid, emails=test_emails) Home.saveShowNotifyList(show=showid, emails=test_emails)
# Now, iterate through all shows using the email list generation routines that are used in the notifier proper # Now, iterate through all shows using the email list generation routines that are used in the notifier proper
shows = self.legacy_shows+self.shows shows = self.legacy_shows+self.shows
for show in shows: for show in shows:
for episode in show.episodes: for episode in show.episodes:
ep_name = ss(episode._format_pattern('%SN - %Sx%0E - %EN - ')+episode.quality) ep_name = ss(episode._format_pattern('%SN - %Sx%0E - %EN - ')+episode.quality) # pylint: disable=protected-access
show_name = email_notifier._parseEp(ep_name) show_name = email_notifier._parseEp(ep_name) # pylint: disable=protected-access
recipients = email_notifier._generate_recipients(show_name) recipients = email_notifier._generate_recipients(show_name) # pylint: disable=protected-access
self._debug_spew("- Email Notifications for "+show.name+" (episode: "+episode.name+") will be sent to:") self._debug_spew("- Email Notifications for "+show.name+" (episode: "+episode.name+") will be sent to:")
for email in recipients: for email in recipients:
self._debug_spew("-- "+email.strip()) self._debug_spew("-- "+email.strip())
...@@ -118,34 +137,73 @@ class NotifierTests(test.SickbeardTestDBCase): ...@@ -118,34 +137,73 @@ class NotifierTests(test.SickbeardTestDBCase):
return True return True
#def test_emby(self): @unittest.skip('Not yet implemented')
# pass def test_emby(self):
"""
#def test_freemobile(self): Test emby notifications
# pass """
pass
#def test_growl(self):
# pass @unittest.skip('Not yet implemented')
def test_freemobile(self):
#def test_kodi(self): """
# pass Test freemobile notifications
"""
#def test_libnotify(self): pass
# pass
@unittest.skip('Not yet implemented')
#def test_nma(self): def test_growl(self):
# pass """
Test growl notifications
#def test_nmj(self): """
# pass pass
#def test_nmjv2(self): @unittest.skip('Not yet implemented')
# pass def test_kodi(self):
"""
#def test_plex(self): Test kodi notifications
# pass """
pass
@unittest.skip('Not yet implemented')
def test_libnotify(self):
"""
Test libnotify notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_nma(self):
"""
Test nma notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_nmj(self):
"""
Test nmj notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_nmjv2(self):
"""
Test nmjv2 notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_plex(self):
"""
Test plex notifications
"""
pass
def test_prowl(self): def test_prowl(self):
"""
Test prowl notifications
"""
prowl_notifier = ProwlNotifier() prowl_notifier = ProwlNotifier()
# Prowl per-show-notifications only utilize the new methodology for storage; therefore, the list of legacy_shows # Prowl per-show-notifications only utilize the new methodology for storage; therefore, the list of legacy_shows
...@@ -159,9 +217,9 @@ class NotifierTests(test.SickbeardTestDBCase): ...@@ -159,9 +217,9 @@ class NotifierTests(test.SickbeardTestDBCase):
# Now, iterate through all shows using the Prowl API generation routines that are used in the notifier proper # Now, iterate through all shows using the Prowl API generation routines that are used in the notifier proper
for show in self.shows: for show in self.shows:
for episode in show.episodes: for episode in show.episodes:
ep_name = ss(episode._format_pattern('%SN - %Sx%0E - %EN - ')+episode.quality) ep_name = ss(episode._format_pattern('%SN - %Sx%0E - %EN - ')+episode.quality) # pylint: disable=protected-access
show_name = prowl_notifier._parse_episode(ep_name) show_name = prowl_notifier._parse_episode(ep_name) # pylint: disable=protected-access
recipients = prowl_notifier._generate_recipients(show_name) recipients = prowl_notifier._generate_recipients(show_name) # pylint: disable=protected-access
self._debug_spew("- Prowl Notifications for "+show.name+" (episode: "+episode.name+") will be sent to:") self._debug_spew("- Prowl Notifications for "+show.name+" (episode: "+episode.name+") will be sent to:")
for api in recipients: for api in recipients:
self._debug_spew("-- "+api.strip()) self._debug_spew("-- "+api.strip())
...@@ -169,36 +227,80 @@ class NotifierTests(test.SickbeardTestDBCase): ...@@ -169,36 +227,80 @@ class NotifierTests(test.SickbeardTestDBCase):
return True return True
#def test_pushalot(self): @unittest.skip('Not yet implemented')
# pass def test_pushalot(self):
"""
#def test_pushbullet(self): Test pushalot notifications
# pass """
pass
#def test_pushover(self):
# pass @unittest.skip('Not yet implemented')
def test_pushbullet(self):
#def test_pytivo(self): """
# pass Test pushbullet notifications
"""
#def test_synoindex(self): pass
# pass
@unittest.skip('Not yet implemented')
#def test_synologynotifier(self): def test_pushover(self):
# pass """
Test pushover notifications
#def test_trakt(self): """
# pass pass
#def test_tweet(self): @unittest.skip('Not yet implemented')
# pass def test_pytivo(self):
"""
Test pytivo notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_synoindex(self):
"""
Test synoindex notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_synologynotifier(self):
"""
Test synologynotifier notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_trakt(self):
"""
Test trakt notifications
"""
pass
@unittest.skip('Not yet implemented')
def test_tweet(self):
"""
Test tweet notifications
"""
pass
@staticmethod @staticmethod
def _debug_spew(text): def _debug_spew(text):
"""
Spew text notifications
:param text: to spew
:return:
"""
if __name__ == '__main__' and text is not None: if __name__ == '__main__' and text is not None:
print text print text
def _get_showid_by_showname(self, showname): def _get_showid_by_showname(self, showname):
"""
Get show ID by show name
:param showname:
:return:
"""
if showname is not None: if showname is not None:
rows = self.mydb.select("SELECT show_id FROM tv_shows WHERE show_name = ?", [showname]) rows = self.mydb.select("SELECT show_id FROM tv_shows WHERE show_name = ?", [showname])
if len(rows) == 1: if len(rows) == 1:
...@@ -210,5 +312,6 @@ if __name__ == '__main__': ...@@ -210,5 +312,6 @@ if __name__ == '__main__':
print "STARTING - NOTIFIER TESTS" print "STARTING - NOTIFIER TESTS"
print "==================" print "=================="
print "######################################################################" print "######################################################################"
SUITE = unittest.TestLoader().loadTestsFromTestCase(NotifierTests) SUITE = unittest.TestLoader().loadTestsFromTestCase(NotifierTests)
unittest.TextTestRunner(verbosity=2).run(SUITE) unittest.TextTestRunner(verbosity=2).run(SUITE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment