2021-03-27 03:56:36 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class SonarrHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "sonarr"
|
2021-03-27 03:56:36 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/sonarr?api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "sonarr"
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_test(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr test payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Sonarr - Test"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "Sonarr webhook has been successfully configured."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_test", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_series_deleted(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr series deleted payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Breaking Bad"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "Breaking Bad has been deleted."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_series_deleted", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_health_check_warning(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr health check warning payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Health warning"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "Indexers unavailable due to failures for more than 6 hours: Academic Torrents - Jackett, ACG - Jackett, KickAssTorrent - Jackett, EXT Torrents - Jackett, Extra Torrents - Jackett, SkyTorrents - Jackett, iDope - Jackett."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_health_check_warning", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_health_check_error(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr health check error payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Health error"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "No indexers available with RSS sync enabled, Sonarr will not grab new releases automatically."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_health_check_error", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episodes_renamed(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episodes renamed payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "The L Word"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "The L Word episodes have been renamed."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episodes_renamed", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episode_imported(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episode imported payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Grey's Anatomy"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "Grey's Anatomy - 17x9 - In My Life has been imported."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episode_imported", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episode_imported_upgrade(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episode imported upgrade payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "NCIS"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "NCIS - 18x10 - Watchdog has been upgraded from SDTV to HDTV-720p."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episode_imported_upgrade", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episode_grabbed(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episode grabbed payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "NCIS"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "NCIS - 18x10 - Watchdog has been grabbed."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episode_grabbed", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episode_deleted(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episode deleted payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Breaking Bad"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = "Breaking Bad - 1x1 - Pilot has been deleted."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episode_deleted", expected_topic_name, expected_message)
|
2021-03-27 03:56:36 +01:00
|
|
|
|
|
|
|
def test_sonarr_episode_deleted_upgrade(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if sonarr episode deleted upgrade payload is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "S.W.A.T. (2017)"
|
2021-03-27 03:56:36 +01:00
|
|
|
expected_message = (
|
|
|
|
"S.W.A.T. (2017) - 4x10 - Buried has been deleted due to quality upgrade."
|
|
|
|
)
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("sonarr_episode_deleted_upgrade", expected_topic_name, expected_message)
|