mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Tests for repack fix and improve behaviour when release group is unknown
This commit is contained in:
parent
2b1fd77ad7
commit
0416060643
@ -84,7 +84,7 @@ public void should_return_true_if_is_a_repack_for_existing_file()
|
||||
}
|
||||
|
||||
[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 @@ public void should_return_false_if_is_a_repack_for_existing_file()
|
||||
.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,6 +377,7 @@ public void should_parse_quality_from_extension(string title)
|
||||
[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);
|
||||
|
@ -31,7 +31,17 @@ public Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCr
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user