1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-26 22:56:23 -04:00

New: Add release info to webhook/custom script import events

Closes #5503
This commit is contained in:
Mark McDowall
2023-04-02 13:26:49 -07:00
parent f59276881a
commit f4130d96e5
12 changed files with 119 additions and 42 deletions
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.History;
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
@@ -40,6 +40,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
_localEpisode = Builder<LocalEpisode>.CreateNew()
.With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic())
.With(l => l.Episodes = new List<Episode> { _episode1 })
.With(l => l.Release = null)
.Build();
_downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
@@ -47,19 +48,8 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
private void GivenHistoryForEpisodes(params Episode[] episodes)
{
var history = new List<EpisodeHistory>();
foreach (var episode in episodes)
{
history.Add(Builder<EpisodeHistory>.CreateNew()
.With(h => h.EventType = EpisodeHistoryEventType.Grabbed)
.With(h => h.EpisodeId = episode.Id)
.Build());
}
Mocker.GetMock<IHistoryService>()
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
.Returns(history);
_localEpisode.Release = new GrabbedReleaseInfo();
_localEpisode.Release.EpisodeIds = episodes.Select(e => e.Id).ToList();
}
[Test]
@@ -77,7 +67,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
public void should_be_accepted_if_no_grab_history()
public void should_be_accepted_if_no_grabbed_release_info()
{
GivenHistoryForEpisodes();
@@ -85,7 +75,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
public void should_be_accepted_if_file_episode_matches_single_grab_history()
public void should_be_accepted_if_file_episode_matches_single_grabbed_release_info()
{
GivenHistoryForEpisodes(_episode1);
@@ -93,7 +83,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
public void should_be_accepted_if_file_episode_is_in_multi_episode_grab_history()
public void should_be_accepted_if_file_episode_is_in_multi_episode_grabbed_release_info()
{
GivenHistoryForEpisodes(_episode1, _episode2);
@@ -101,7 +91,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
public void should_be_rejected_if_file_episode_does_not_match_single_grab_history()
public void should_be_rejected_if_file_episode_does_not_match_single_grabbed_release_info()
{
GivenHistoryForEpisodes(_episode2);
@@ -109,7 +99,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
}
[Test]
public void should_be_rejected_if_file_episode_is_not_in_multi_episode_grab_history()
public void should_be_rejected_if_file_episode_is_not_in_multi_episode_grabbed_release_info()
{
GivenHistoryForEpisodes(_episode2, _episode3);