Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage-1
Commits
4b6acf51
Commit
4b6acf51
authored
Nov 28, 2015
by
labrys
Browse files
Options
Downloads
Plain Diff
Merge pull request #250 from labrys/lint-notifier_tests
Lint 10/10
parents
c11c6d0a
0eaa5993
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/notifier_tests.py
+167
-64
167 additions, 64 deletions
tests/notifier_tests.py
with
167 additions
and
64 deletions
tests/notifier_tests.py
+
167
−
64
View file @
4b6acf51
...
...
@@ -20,16 +20,23 @@
###
# 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:
# pylint: disable=W0212
# classes in order to test those classes. Therefore we will be pylint disable protected-access
###
import
sys
,
os
.
path
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__
),
'
..
'
)))
# pylint: disable=line-too-long
"""
Test notifiers
"""
import
sys
import
os.path
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
from
sickbeard
import
db
...
...
@@ -40,8 +47,11 @@ from sickbeard.notifiers.prowl import ProwlNotifier
from
sickrage.helper.encoding
import
ss
class
NotifierTests
(
test
.
SickbeardTestDBCase
):
class
NotifierTests
(
test
.
SickbeardTestDBCase
):
# pylint: disable=too-many-public-methods
"""
Test notifiers
"""
@classmethod
def
setUpClass
(
cls
):
num_legacy_shows
=
3
...
...
@@ -81,12 +91,22 @@ class NotifierTests(test.SickbeardTestDBCase):
cls
.
shows
.
append
(
show
)
def
setUp
(
self
):
"""
Set up tests
"""
self
.
_debug_spew
(
"
\n\r
"
)
#def test_boxcar(self):
# pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_boxcar
(
self
):
"""
Test boxcar notifications
"""
pass
def
test_email
(
self
):
"""
Test email notifications
"""
email_notifier
=
EmailNotifier
()
# 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):
showid
=
self
.
_get_showid_by_showname
(
show
.
name
)
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
shows
=
self
.
legacy_shows
+
self
.
shows
for
show
in
shows
:
for
episode
in
show
.
episodes
:
ep_name
=
ss
(
episode
.
_format_pattern
(
'
%SN - %Sx%0E - %EN -
'
)
+
episode
.
quality
)
show_name
=
email_notifier
.
_parseEp
(
ep_name
)
recipients
=
email_notifier
.
_generate_recipients
(
show_name
)
ep_name
=
ss
(
episode
.
_format_pattern
(
'
%SN - %Sx%0E - %EN -
'
)
+
episode
.
quality
)
# pylint: disable=protected-access
show_name
=
email_notifier
.
_parseEp
(
ep_name
)
# pylint: disable=protected-access
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:
"
)
for
email
in
recipients
:
self
.
_debug_spew
(
"
--
"
+
email
.
strip
())
...
...
@@ -118,34 +137,73 @@ class NotifierTests(test.SickbeardTestDBCase):
return
True
#def test_emby(self):
# pass
#def test_freemobile(self):
# pass
#def test_growl(self):
# pass
#def test_kodi(self):
# pass
#def test_libnotify(self):
# pass
#def test_nma(self):
# pass
#def test_nmj(self):
# pass
#def test_nmjv2(self):
# pass
#def test_plex(self):
# pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_emby
(
self
):
"""
Test emby notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_freemobile
(
self
):
"""
Test freemobile notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_growl
(
self
):
"""
Test growl notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_kodi
(
self
):
"""
Test kodi notifications
"""
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
):
"""
Test prowl notifications
"""
prowl_notifier
=
ProwlNotifier
()
# 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):
# Now, iterate through all shows using the Prowl API generation routines that are used in the notifier proper
for
show
in
self
.
shows
:
for
episode
in
show
.
episodes
:
ep_name
=
ss
(
episode
.
_format_pattern
(
'
%SN - %Sx%0E - %EN -
'
)
+
episode
.
quality
)
show_name
=
prowl_notifier
.
_parse_episode
(
ep_name
)
recipients
=
prowl_notifier
.
_generate_recipients
(
show_name
)
ep_name
=
ss
(
episode
.
_format_pattern
(
'
%SN - %Sx%0E - %EN -
'
)
+
episode
.
quality
)
# pylint: disable=protected-access
show_name
=
prowl_notifier
.
_parse_episode
(
ep_name
)
# pylint: disable=protected-access
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:
"
)
for
api
in
recipients
:
self
.
_debug_spew
(
"
--
"
+
api
.
strip
())
...
...
@@ -169,36 +227,80 @@ class NotifierTests(test.SickbeardTestDBCase):
return
True
#def test_pushalot(self):
# pass
#def test_pushbullet(self):
# pass
#def test_pushover(self):
# pass
#def test_pytivo(self):
# pass
#def test_synoindex(self):
# pass
#def test_synologynotifier(self):
# pass
#def test_trakt(self):
# pass
#def test_tweet(self):
# pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_pushalot
(
self
):
"""
Test pushalot notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_pushbullet
(
self
):
"""
Test pushbullet notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
def
test_pushover
(
self
):
"""
Test pushover notifications
"""
pass
@unittest.skip
(
'
Not yet implemented
'
)
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
def
_debug_spew
(
text
):
"""
Spew text notifications
:param text: to spew
:return:
"""
if
__name__
==
'
__main__
'
and
text
is
not
None
:
print
text
def
_get_showid_by_showname
(
self
,
showname
):
"""
Get show ID by show name
:param showname:
:return:
"""
if
showname
is
not
None
:
rows
=
self
.
mydb
.
select
(
"
SELECT show_id FROM tv_shows WHERE show_name = ?
"
,
[
showname
])
if
len
(
rows
)
==
1
:
...
...
@@ -210,5 +312,6 @@ if __name__ == '__main__':
print
"
STARTING - NOTIFIER TESTS
"
print
"
==================
"
print
"
######################################################################
"
SUITE
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
NotifierTests
)
unittest
.
TextTestRunner
(
verbosity
=
2
).
run
(
SUITE
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment