Tests for repack fix and improve behaviour when release group is unknown

This commit is contained in:
Mark McDowall 2019-05-05 13:01:16 -07:00
parent 2b1fd77ad7
commit 0416060643
3 changed files with 55 additions and 2 deletions

View File

@ -84,7 +84,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
}
[Test]
public void should_return_false_if_is_a_repack_for_existing_file()
public void should_return_false_if_is_a_repack_for_a_different_file()
{
_parsedEpisodeInfo.Quality.Revision.IsRepack = true;
_episodes.First().EpisodeFileId = 1;
@ -102,5 +102,47 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
.Should()
.BeFalse();
}
[Test]
public void should_return_false_if_release_group_for_existing_file_is_unknown()
{
_parsedEpisodeInfo.Quality.Revision.IsRepack = true;
_episodes.First().EpisodeFileId = 1;
_episodes.First().EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.ReleaseGroup = "")
.Build();
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
.With(e => e.ParsedEpisodeInfo = _parsedEpisodeInfo)
.With(e => e.Episodes = _episodes)
.Build();
Subject.IsSatisfiedBy(remoteEpisode, null)
.Accepted
.Should()
.BeFalse();
}
[Test]
public void should_return_false_if_release_group_for_release_is_unknown()
{
_parsedEpisodeInfo.Quality.Revision.IsRepack = true;
_parsedEpisodeInfo.ReleaseGroup = null;
_episodes.First().EpisodeFileId = 1;
_episodes.First().EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(e => e.ReleaseGroup = "Sonarr")
.Build();
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
.With(e => e.ParsedEpisodeInfo = _parsedEpisodeInfo)
.With(e => e.Episodes = _episodes)
.Build();
Subject.IsSatisfiedBy(remoteEpisode, null)
.Accepted
.Should()
.BeFalse();
}
}
}

View File

@ -377,6 +377,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Series Title S04E87 REPACK 720p HDTV x264 aAF", true)]
[TestCase("Series.Title.S04E87.REPACK.720p.HDTV.x264-aAF", true)]
[TestCase("Series.Title.S04E87.PROPER.720p.HDTV.x264-aAF", false)]
[TestCase("The.Expanse.S01E07.RERIP.720p.BluRay.x264-DEMAND", true)]
public void should_be_able_to_parse_repack(string title, bool isRepack)
{
var result = QualityParser.ParseQuality(title);

View File

@ -31,7 +31,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup;
var fileReleaseGroup = file.ReleaseGroup;
if (fileReleaseGroup.IsNotNullOrWhiteSpace() && !fileReleaseGroup.Equals(releaseGroup, StringComparison.InvariantCultureIgnoreCase))
if (fileReleaseGroup.IsNullOrWhiteSpace())
{
return Decision.Reject("Unable to determine release group for the existing file");
}
if (releaseGroup.IsNullOrWhiteSpace())
{
return Decision.Reject("Unable to determine release group for this release");
}
if (!fileReleaseGroup.Equals(releaseGroup, StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Release is a repack for a different release group. Release Group: {0}. File release group: {0}", releaseGroup, fileReleaseGroup);
return Decision.Reject("Release is a repack for a different release group. Release Group: {0}. File release group: {0}", releaseGroup, fileReleaseGroup);