New: Health Check Failure Notifications (#609)

* New: Health Check Failure Notifications

Fixes #295

* New: OnDownloadFailure and OnImportFailure Notification

* New: On Retag notifications

* Fixed: XBMC notification test

* New: Discord Notifications

Closes #1511

* On Download to On Import on card

* Remove OnDownload, Rename OnAlbumDownload -> OnReleaseImported

* Fixed: Webhook OnReleaseImport notification

* Respect OnUpgrade and fix missing schema items for frontend

* New: Simplify Notification Modal UI

* Fixed: PlexHomeTheater OnReleaseImport notification
This commit is contained in:
Qstick
2019-03-21 20:47:54 -04:00
committed by GitHub
parent 4d8bcd12e3
commit d4d9146599
52 changed files with 1262 additions and 427 deletions
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test.NotificationTests
}
}
class TestNotificationWithOnDownload : NotificationBase<TestSetting>
class TestNotificationWithOnReleaseImport : NotificationBase<TestSetting>
{
public override string Name => "TestNotification";
public override string Link => "";
@@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.NotificationTests
throw new NotImplementedException();
}
public override void OnDownload(TrackDownloadMessage trackDownloadMessage)
public override void OnReleaseImport(AlbumDownloadMessage message)
{
TestLogger.Info("OnDownload was called");
}
@@ -55,12 +55,7 @@ namespace NzbDrone.Core.Test.NotificationTests
TestLogger.Info("OnGrab was called");
}
public override void OnDownload(TrackDownloadMessage message)
{
TestLogger.Info("OnDownload was called");
}
public override void OnAlbumDownload(AlbumDownloadMessage message)
public override void OnReleaseImport(AlbumDownloadMessage message)
{
TestLogger.Info("OnAlbumDownload was called");
}
@@ -70,6 +65,25 @@ namespace NzbDrone.Core.Test.NotificationTests
TestLogger.Info("OnRename was called");
}
public override void OnHealthIssue(NzbDrone.Core.HealthCheck.HealthCheck artist)
{
TestLogger.Info("OnHealthIssue was called");
}
public override void OnDownloadFailure(DownloadFailedMessage message)
{
TestLogger.Info("OnDownloadFailure was called");
}
public override void OnImportFailure(AlbumDownloadMessage message)
{
TestLogger.Info("OnImportFailure was called");
}
public override void OnTrackRetag(TrackRetagMessage message)
{
TestLogger.Info("OnTrackRetag was called");
}
}
class TestNotificationWithNoEvents : NotificationBase<TestSetting>
@@ -87,11 +101,11 @@ namespace NzbDrone.Core.Test.NotificationTests
}
[Test]
public void should_support_OnUpgrade_should_link_to_OnDownload()
public void should_support_OnUpgrade_should_link_to_OnReleaseImport()
{
var notification = new TestNotificationWithOnDownload();
var notification = new TestNotificationWithOnReleaseImport();
notification.SupportsOnDownload.Should().BeTrue();
notification.SupportsOnReleaseImport.Should().BeTrue();
notification.SupportsOnUpgrade.Should().BeTrue();
notification.SupportsOnGrab.Should().BeFalse();
@@ -104,10 +118,13 @@ namespace NzbDrone.Core.Test.NotificationTests
var notification = new TestNotificationWithAllEvents();
notification.SupportsOnGrab.Should().BeTrue();
notification.SupportsOnDownload.Should().BeTrue();
notification.SupportsOnAlbumDownload.Should().BeTrue();
notification.SupportsOnReleaseImport.Should().BeTrue();
notification.SupportsOnUpgrade.Should().BeTrue();
notification.SupportsOnRename.Should().BeTrue();
notification.SupportsOnHealthIssue.Should().BeTrue();
notification.SupportsOnDownloadFailure.Should().BeTrue();
notification.SupportsOnImportFailure.Should().BeTrue();
notification.SupportsOnTrackRetag.Should().BeTrue();
}
@@ -117,10 +134,13 @@ namespace NzbDrone.Core.Test.NotificationTests
var notification = new TestNotificationWithNoEvents();
notification.SupportsOnGrab.Should().BeFalse();
notification.SupportsOnDownload.Should().BeFalse();
notification.SupportsOnAlbumDownload.Should().BeFalse();
notification.SupportsOnReleaseImport.Should().BeFalse();
notification.SupportsOnUpgrade.Should().BeFalse();
notification.SupportsOnRename.Should().BeFalse();
notification.SupportsOnHealthIssue.Should().BeFalse();
notification.SupportsOnDownloadFailure.Should().BeFalse();
notification.SupportsOnImportFailure.Should().BeFalse();
notification.SupportsOnTrackRetag.Should().BeFalse();
}
}
@@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.NotificationTests
[Test]
public void should_remove_old_episodes_on_upgrade()
{
Subject.OnAlbumDownload(_upgrade);
Subject.OnReleaseImport(_upgrade);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.DeleteFile(@"C:\Test\file1.S01E01.mkv".AsOsAgnostic()), Times.Once());
@@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests
[Test]
public void should_add_new_episode_on_upgrade()
{
Subject.OnAlbumDownload(_upgrade);
Subject.OnReleaseImport(_upgrade);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.AddFile(@"C:\Test\file1.S01E01E02.mkv".AsOsAgnostic()), Times.Once());
@@ -24,10 +24,12 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
.Build();
_xbmcArtist = Builder<KodiArtist>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.MusicbrainzArtistId = new List<string> { MB_ID.ToString()})
.Build()
.ToList();
.TheFirst(1)
.With(s => s.MusicbrainzArtistId = new List<string> { MB_ID.ToString()})
.TheNext(2)
.With(s => s.MusicbrainzArtistId = new List<string>())
.Build()
.ToList();
Mocker.GetMock<IXbmcJsonApiProxy>()
.Setup(s => s.GetArtist(_settings))
@@ -12,9 +12,9 @@ using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
{
[TestFixture]
public class OnDownloadFixture : CoreTest<Notifications.Xbmc.Xbmc>
public class OnReleaseImportFixture : CoreTest<Notifications.Xbmc.Xbmc>
{
private TrackDownloadMessage _trackDownloadMessage;
private AlbumDownloadMessage _albumDownloadMessage;
[SetUp]
public void Setup()
@@ -25,11 +25,11 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
var trackFile = Builder<TrackFile>.CreateNew()
.Build();
_trackDownloadMessage = Builder<TrackDownloadMessage>.CreateNew()
.With(d => d.Artist = artist)
.With(d => d.TrackFile = trackFile)
.With(d => d.OldFiles = new List<TrackFile>())
.Build();
_albumDownloadMessage = Builder<AlbumDownloadMessage>.CreateNew()
.With(d => d.Artist = artist)
.With(d => d.TrackFiles = new List<TrackFile> { trackFile })
.With(d => d.OldFiles = new List<TrackFile>())
.Build();
Subject.Definition = new NotificationDefinition();
Subject.Definition.Settings = new XbmcSettings
@@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
private void GivenOldFiles()
{
_trackDownloadMessage.OldFiles = Builder<TrackFile>.CreateListOfSize(1)
_albumDownloadMessage.OldFiles = Builder<TrackFile>.CreateListOfSize(1)
.Build()
.ToList();
@@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
[Test]
public void should_not_clean_if_no_episode_was_replaced()
{
Subject.OnDownload(_trackDownloadMessage);
Subject.OnReleaseImport(_albumDownloadMessage);
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Never());
}
@@ -63,7 +63,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
public void should_clean_if_episode_was_replaced()
{
GivenOldFiles();
Subject.OnDownload(_trackDownloadMessage);
Subject.OnReleaseImport(_albumDownloadMessage);
Mocker.GetMock<IXbmcService>().Verify(v => v.Clean(It.IsAny<XbmcSettings>()), Times.Once());
}