mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 10:32:35 +01:00
QualityParseTest will accept bool IsProper as a parameter.
IsUpgrade will take into account that a proper of the same quality should be accepted even if the cutoff was met.
This commit is contained in:
parent
d6d1bbe3f5
commit
197979ea3c
@ -102,6 +102,7 @@
|
||||
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
|
||||
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
|
||||
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
|
||||
<Compile Include="ProviderTests\InventoryProviderTests\IsUpgradeFixture.cs" />
|
||||
<Compile Include="ProviderTests\InventoryProviderTests\IsUpgradePossibleFixture.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProviderTests\CleanUpDatabaseFixture.cs" />
|
||||
<Compile Include="ProviderTests\ReferenceDataProviderTest.cs" />
|
||||
|
@ -104,44 +104,46 @@ public void unparsable_title()
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD)]
|
||||
[TestCase("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)]
|
||||
[TestCase("this has no extention or periods HDTV", QualityTypes.SDTV)]
|
||||
[TestCase("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV)]
|
||||
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown)]
|
||||
[TestCase("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV)]
|
||||
[TestCase("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV)]
|
||||
[TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p)]
|
||||
[TestCase("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p)]
|
||||
[TestCase("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
|
||||
[TestCase("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown)]
|
||||
[TestCase("(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown)]
|
||||
[TestCase("S07E23 - [HDTV].mkv ", QualityTypes.HDTV)]
|
||||
[TestCase("S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL)]
|
||||
[TestCase("S07E23.mkv ", QualityTypes.HDTV)]
|
||||
[TestCase("S07E23 .avi ", QualityTypes.SDTV)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p)]
|
||||
[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.Unknown)]
|
||||
[TestCase("Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV)]
|
||||
public void quality_parse(string postTitle, object quality)
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD, false)]
|
||||
[TestCase("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV, false)]
|
||||
[TestCase("this has no extention or periods HDTV", QualityTypes.SDTV, false)]
|
||||
[TestCase("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV, false)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD, false)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD, false)]
|
||||
[TestCase("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV, false)]
|
||||
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV, false)]
|
||||
[TestCase("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown, false)]
|
||||
[TestCase("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV, false)]
|
||||
[TestCase("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV, false)]
|
||||
[TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p, false)]
|
||||
[TestCase("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p, false)]
|
||||
[TestCase("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
|
||||
[TestCase("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown, false)]
|
||||
[TestCase("(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown, false)]
|
||||
[TestCase("S07E23 - [HDTV].mkv ", QualityTypes.HDTV, false)]
|
||||
[TestCase("S07E23 - [WEBDL].mkv ", QualityTypes.WEBDL, false)]
|
||||
[TestCase("S07E23.mkv ", QualityTypes.HDTV, false)]
|
||||
[TestCase("S07E23 .avi ", QualityTypes.SDTV, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD, false)]
|
||||
[TestCase("WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p, false)]
|
||||
[TestCase("The Voice S01E11 The Finals 1080i HDTV DD5.1 MPEG2-TrollHD", QualityTypes.Unknown, false)]
|
||||
[TestCase("Nikita S02E01 HDTV XviD 2HD", QualityTypes.SDTV, false)]
|
||||
[TestCase("Gossip Girl S05E11 PROPER HDTV XviD 2HD", QualityTypes.SDTV, true)]
|
||||
public void quality_parse(string postTitle, object quality, bool proper)
|
||||
{
|
||||
var result = Parser.ParseQuality(postTitle);
|
||||
result.QualityType.Should().Be(quality);
|
||||
result.Proper.Should().Be(proper);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -0,0 +1,127 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.InventoryProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class IsUpgradeFixture : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_true_if_new_is_proper_and_current_isnt_even_if_cutoff_is_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.SDTV, false);
|
||||
var newQuality = new Quality(QualityTypes.SDTV, true);
|
||||
var cutoff = QualityTypes.SDTV;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_true_if_new_quality_is_better_than_current_and_cutoff_is_not_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.SDTV, false);
|
||||
var newQuality = new Quality(QualityTypes.DVD, true);
|
||||
var cutoff = QualityTypes.DVD;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_false_if_new_quality_is_same_as_current_and_cutoff_is_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.SDTV, false);
|
||||
var newQuality = new Quality(QualityTypes.SDTV, false);
|
||||
var cutoff = QualityTypes.SDTV;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_false_if_new_quality_is_better_than_current_and_cutoff_is_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.SDTV, false);
|
||||
var newQuality = new Quality(QualityTypes.DVD, true);
|
||||
var cutoff = QualityTypes.SDTV;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_false_if_new_quality_is_worse_than_current_and_cutoff_is_not_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.WEBDL, false);
|
||||
var newQuality = new Quality(QualityTypes.HDTV, true);
|
||||
var cutoff = QualityTypes.Bluray720p;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_false_if_new_quality_is_worse_than_current_and_cutoff_is_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.WEBDL, false);
|
||||
var newQuality = new Quality(QualityTypes.HDTV, true);
|
||||
var cutoff = QualityTypes.WEBDL;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_false_if_new_quality_is_the_same_as_current_and_cutoff_is_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.WEBDL, false);
|
||||
var newQuality = new Quality(QualityTypes.WEBDL, false);
|
||||
var cutoff = QualityTypes.WEBDL;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsUpgrade_should_return_true_if_new_quality_is_a_proper_with_the_same_quality_as_current_and_cutoff_is_not_met()
|
||||
{
|
||||
var currentQuality = new Quality(QualityTypes.WEBDL, false);
|
||||
var newQuality = new Quality(QualityTypes.WEBDL, true);
|
||||
var cutoff = QualityTypes.Bluray720p;
|
||||
|
||||
var result = InventoryProvider.IsUpgrade(currentQuality, newQuality, cutoff);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
@ -125,8 +125,12 @@ public static bool IsUpgrade(Quality currentQuality, Quality newQuality, Quality
|
||||
{
|
||||
if (currentQuality.QualityType >= cutOff)
|
||||
{
|
||||
Logger.Trace("Existing item meets cut-off. skipping.");
|
||||
return false;
|
||||
if (newQuality.QualityType > currentQuality.QualityType ||
|
||||
(newQuality.QualityType == currentQuality.QualityType && newQuality.Proper == currentQuality.Proper))
|
||||
{
|
||||
Logger.Trace("Existing item meets cut-off. skipping.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (newQuality > currentQuality)
|
||||
@ -140,7 +144,7 @@ public static bool IsUpgrade(Quality currentQuality, Quality newQuality, Quality
|
||||
|
||||
if (currentQuality == newQuality && !newQuality.Proper)
|
||||
{
|
||||
Logger.Trace("same quality. not proper skipping");
|
||||
Logger.Trace("Same quality, not proper skipping");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user