mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-23 22:25:56 -04:00
New: Custom Formats
Co-Authored-By: ta264 <ta264@users.noreply.github.com>
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.CustomFormats;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class CustomFormatAllowedByProfileSpecificationFixture : CoreTest<CustomFormatAllowedbyProfileSpecification>
|
||||
{
|
||||
private RemoteEpisode _remoteEpisode;
|
||||
|
||||
private CustomFormat _format1;
|
||||
private CustomFormat _format2;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_format1 = new CustomFormat("Awesome Format");
|
||||
_format1.Id = 1;
|
||||
|
||||
_format2 = new CustomFormat("Cool Format");
|
||||
_format2.Id = 2;
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
MinFormatScore = 1
|
||||
})
|
||||
.Build();
|
||||
|
||||
_remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)) },
|
||||
};
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(_format1, _format2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_allow_if_format_score_greater_than_min()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { _format1 };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_format_score_not_greater_than_min()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { _format2 };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Console.WriteLine(_remoteEpisode.CustomFormatScore);
|
||||
Console.WriteLine(_remoteEpisode.Series.QualityProfile.Value.MinFormatScore);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_format_score_not_greater_than_min_2()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name);
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_allow_if_all_format_is_defined_in_profile()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { _format2, _format1 };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_deny_if_no_format_was_parsed_and_min_score_positive()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_allow_if_no_format_was_parsed_min_score_is_zero()
|
||||
{
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { };
|
||||
_remoteEpisode.Series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems(_format1.Name, _format2.Name);
|
||||
_remoteEpisode.Series.QualityProfile.Value.MinFormatScore = 0;
|
||||
_remoteEpisode.CustomFormatScore = _remoteEpisode.Series.QualityProfile.Value.CalculateCustomFormatScore(_remoteEpisode.CustomFormats);
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,367 +1,385 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Serializer;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.CustomFormats;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Test.Languages;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CutoffSpecificationFixture : CoreTest<UpgradableSpecification>
|
||||
public class CutoffSpecificationFixture : CoreTest<CutoffSpecification>
|
||||
{
|
||||
private static readonly int NoPreferredWordScore = 0;
|
||||
private CustomFormat _customFormat;
|
||||
private RemoteEpisode _remoteMovie;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.SetConstant<IUpgradableSpecification>(Mocker.Resolve<UpgradableSpecification>());
|
||||
|
||||
_remoteMovie = new RemoteEpisode()
|
||||
{
|
||||
Series = Builder<Series>.CreateNew().Build(),
|
||||
Episodes = new List<Episode> { Builder<Episode>.CreateNew().Build() },
|
||||
ParsedEpisodeInfo = Builder<ParsedEpisodeInfo>.CreateNew().With(x => x.Quality = null).Build()
|
||||
};
|
||||
|
||||
GivenOldCustomFormats(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
private void GivenProfile(QualityProfile profile)
|
||||
{
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
profile.FormatItems = CustomFormatsFixture.GetSampleFormatItems();
|
||||
profile.MinFormatScore = 0;
|
||||
_remoteMovie.Series.QualityProfile = profile;
|
||||
|
||||
Console.WriteLine(profile.ToJson());
|
||||
}
|
||||
|
||||
private void GivenLanguageProfile(LanguageProfile profile)
|
||||
{
|
||||
_remoteMovie.Series.LanguageProfile = profile;
|
||||
|
||||
Console.WriteLine(profile.ToJson());
|
||||
}
|
||||
|
||||
private void GivenFileQuality(QualityModel quality, Language language)
|
||||
{
|
||||
_remoteMovie.Episodes.First().EpisodeFile = Builder<EpisodeFile>.CreateNew().With(x => x.Quality = quality).With(x => x.Language = language).Build();
|
||||
}
|
||||
|
||||
private void GivenNewQuality(QualityModel quality)
|
||||
{
|
||||
_remoteMovie.ParsedEpisodeInfo.Quality = quality;
|
||||
}
|
||||
|
||||
private void GivenOldCustomFormats(List<CustomFormat> formats)
|
||||
{
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<EpisodeFile>()))
|
||||
.Returns(formats);
|
||||
}
|
||||
|
||||
private void GivenNewCustomFormats(List<CustomFormat> formats)
|
||||
{
|
||||
_remoteMovie.CustomFormats = formats;
|
||||
}
|
||||
|
||||
private void GivenCustomFormatHigher()
|
||||
{
|
||||
_customFormat = new CustomFormat("My Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 1 };
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(_customFormat);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_current_episode_is_less_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new QualityModel(Quality.DVD, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.DVD, new Revision(version: 2)), Language.English);
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_episode_is_equal_to_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.English);
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_current_episode_is_greater_than_cutoff()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), Language.English);
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_new_episode_is_proper_but_existing_is_not()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 1)), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_cutoff_is_met_and_quality_is_higher()
|
||||
{
|
||||
Subject.CutoffNotMet(
|
||||
new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
},
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
});
|
||||
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_quality_cutoff_is_met_and_quality_is_higher_but_language_is_not_met()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Cutoff = Language.Spanish,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_language_is_met()
|
||||
public void should_return_false_if_quality_cutoff_is_met_and_quality_is_higher_but_language_is_met()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Cutoff = Language.Spanish,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.Spanish,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.Spanish);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_cutoff_is_met_and_quality_is_higher_and_language_is_higher()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Cutoff = Language.Spanish,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.French,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p, new Revision(version: 2)), Language.French);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_cutoff_is_not_met_and_new_quality_is_higher_and_language_is_higher()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Cutoff = Language.Spanish,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.SDTV, new Revision(version: 2)),
|
||||
Language.French,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenFileQuality(new QualityModel(Quality.SDTV, new Revision(version: 2)), Language.French);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p, new Revision(version: 2)));
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_cutoff_is_not_met_and_language_is_higher()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Cutoff = Language.Spanish,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.SDTV, new Revision(version: 2)),
|
||||
Language.French,
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenFileQuality(new QualityModel(Quality.SDTV, new Revision(version: 2)), Language.French);
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_cutoffs_are_met_and_score_is_higher()
|
||||
public void should_return_false_if_custom_formats_is_met_and_quality_and_format_higher()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV720p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
MinFormatScore = 0,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("My Format"),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Spanish,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
|
||||
Language.Spanish,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
|
||||
10).Should().BeTrue();
|
||||
GivenFileQuality(new QualityModel(Quality.HDTV720p), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p));
|
||||
|
||||
GivenCustomFormatHigher();
|
||||
|
||||
GivenOldCustomFormats(new List<CustomFormat>());
|
||||
GivenNewCustomFormats(new List<CustomFormat> { _customFormat });
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.HDTV1080p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.WEBDL1080p, new Revision(version: 2)),
|
||||
NoPreferredWordScore).Should().BeTrue();
|
||||
GivenFileQuality(new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.WEBDL1080p, new Revision(version: 2)));
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_language_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_language_and_quality_cutoff_is_met()
|
||||
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
GivenProfile(new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.WEBDL1080p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
{
|
||||
Cutoff = Language.Arabic,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.Spanish, Language.English, Language.Arabic),
|
||||
UpgradeAllowed = false
|
||||
};
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.WEBDL1080p),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p),
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality_and_language_cutoff_is_met()
|
||||
{
|
||||
QualityProfile profile = new QualityProfile
|
||||
{
|
||||
Cutoff = Quality.WEBDL1080p.Id,
|
||||
Cutoff = Quality.RAWHD.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
UpgradeAllowed = false
|
||||
};
|
||||
});
|
||||
|
||||
LanguageProfile langProfile = new LanguageProfile
|
||||
GivenLanguageProfile(new LanguageProfile
|
||||
{
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.English),
|
||||
Cutoff = Language.English,
|
||||
Languages = LanguageFixture.GetDefaultLanguages(Language.Spanish, Language.English, Language.Arabic),
|
||||
UpgradeAllowed = true
|
||||
};
|
||||
});
|
||||
|
||||
Subject.CutoffNotMet(
|
||||
profile,
|
||||
langProfile,
|
||||
new QualityModel(Quality.WEBDL1080p),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new QualityModel(Quality.Bluray1080p),
|
||||
NoPreferredWordScore).Should().BeFalse();
|
||||
GivenFileQuality(new QualityModel(Quality.WEBDL1080p), Language.English);
|
||||
GivenNewQuality(new QualityModel(Quality.Bluray1080p));
|
||||
|
||||
Subject.IsSatisfiedBy(_remoteMovie, null).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
@@ -471,15 +471,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p), Language.English);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p), Language.English);
|
||||
|
||||
remoteEpisode1.PreferredWordScore = 10;
|
||||
remoteEpisode2.PreferredWordScore = 0;
|
||||
remoteEpisode1.CustomFormatScore = 10;
|
||||
remoteEpisode2.CustomFormatScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
decisions.Add(new DownloadDecision(remoteEpisode2));
|
||||
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteEpisode.PreferredWordScore.Should().Be(10);
|
||||
qualifiedReports.First().RemoteEpisode.CustomFormatScore.Should().Be(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -492,8 +492,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(1)), Language.English);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(2)), Language.English);
|
||||
|
||||
remoteEpisode1.PreferredWordScore = 10;
|
||||
remoteEpisode2.PreferredWordScore = 0;
|
||||
remoteEpisode1.CustomFormatScore = 10;
|
||||
remoteEpisode2.CustomFormatScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
@@ -513,8 +513,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(1)), Language.English);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(2)), Language.English);
|
||||
|
||||
remoteEpisode1.PreferredWordScore = 10;
|
||||
remoteEpisode2.PreferredWordScore = 0;
|
||||
remoteEpisode1.CustomFormatScore = 10;
|
||||
remoteEpisode2.CustomFormatScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
@@ -534,8 +534,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(1)), Language.English);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(2)), Language.English);
|
||||
|
||||
remoteEpisode1.PreferredWordScore = 10;
|
||||
remoteEpisode2.PreferredWordScore = 0;
|
||||
remoteEpisode1.CustomFormatScore = 10;
|
||||
remoteEpisode2.CustomFormatScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
@@ -544,7 +544,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var qualifiedReports = Subject.PrioritizeDecisions(decisions);
|
||||
qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Quality.Should().Be(Quality.WEBDL1080p);
|
||||
qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.Should().Be(1);
|
||||
qualifiedReports.First().RemoteEpisode.PreferredWordScore.Should().Be(10);
|
||||
qualifiedReports.First().RemoteEpisode.CustomFormatScore.Should().Be(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -557,8 +557,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisode1 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(1, 0)), Language.English);
|
||||
var remoteEpisode2 = GivenRemoteEpisode(new List<Episode> { GivenEpisode(1) }, new QualityModel(Quality.WEBDL1080p, new Revision(1, 1)), Language.English);
|
||||
|
||||
remoteEpisode1.PreferredWordScore = 10;
|
||||
remoteEpisode2.PreferredWordScore = 0;
|
||||
remoteEpisode1.CustomFormatScore = 10;
|
||||
remoteEpisode2.CustomFormatScore = 0;
|
||||
|
||||
var decisions = new List<DownloadDecision>();
|
||||
decisions.Add(new DownloadDecision(remoteEpisode1));
|
||||
@@ -568,7 +568,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Quality.Should().Be(Quality.WEBDL1080p);
|
||||
qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Revision.Version.Should().Be(1);
|
||||
qualifiedReports.First().RemoteEpisode.ParsedEpisodeInfo.Quality.Revision.Real.Should().Be(0);
|
||||
qualifiedReports.First().RemoteEpisode.PreferredWordScore.Should().Be(10);
|
||||
qualifiedReports.First().RemoteEpisode.CustomFormatScore.Should().Be(10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -2,15 +2,19 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Download.TrackedDownloads;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Queue;
|
||||
using NzbDrone.Core.Test.CustomFormats;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@@ -33,11 +37,15 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
_series = Builder<Series>.CreateNew()
|
||||
.With(e => e.QualityProfile = new QualityProfile
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems(),
|
||||
MinFormatScore = 0
|
||||
})
|
||||
.With(l => l.LanguageProfile = new LanguageProfile
|
||||
{
|
||||
@@ -69,8 +77,12 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD), Language = Language.Spanish })
|
||||
.With(r => r.PreferredWordScore = 0)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
private void GivenEmptyQueue()
|
||||
@@ -80,6 +92,13 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.Returns(new List<Queue.Queue>());
|
||||
}
|
||||
|
||||
private void GivenQueueFormats(List<CustomFormat> formats)
|
||||
{
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<ParsedEpisodeInfo>()))
|
||||
.Returns(formats);
|
||||
}
|
||||
|
||||
private void GivenQueue(IEnumerable<RemoteEpisode> remoteEpisodes, TrackedDownloadState trackedDownloadState = TrackedDownloadState.Downloading)
|
||||
{
|
||||
var queue = remoteEpisodes.Select(remoteEpisode => new Queue.Queue
|
||||
@@ -107,6 +126,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
.With(r => r.Series = _otherSeries)
|
||||
.With(r => r.Episodes = new List<Episode> { _episode })
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -126,6 +146,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Quality = new QualityModel(Quality.DVD),
|
||||
Language = Language.Spanish
|
||||
})
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.Build();
|
||||
|
||||
@@ -149,6 +170,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -170,6 +192,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -187,6 +210,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Quality = new QualityModel(Quality.DVD)
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -194,9 +218,17 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_true_when_qualities_are_the_same_and_languages_are_the_same_with_higher_preferred_word_score()
|
||||
public void should_return_true_when_qualities_are_the_same_and_languages_are_the_same_with_higher_custom_format_score()
|
||||
{
|
||||
_remoteEpisode.PreferredWordScore = 1;
|
||||
_remoteEpisode.CustomFormats = new List<CustomFormat> { new CustomFormat("My Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 1 } };
|
||||
|
||||
var lowFormat = new List<CustomFormat> { new CustomFormat("Bad Format", new ResolutionSpecification { Value = (int)Resolution.R1080p }) { Id = 2 } };
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats(_remoteEpisode.CustomFormats.First(), lowFormat.First());
|
||||
|
||||
_series.QualityProfile.Value.FormatItems = CustomFormatsFixture.GetSampleFormatItems("My Format");
|
||||
|
||||
GivenQueueFormats(lowFormat);
|
||||
|
||||
var remoteEpisode = Builder<RemoteEpisode>.CreateNew()
|
||||
.With(r => r.Series = _series)
|
||||
@@ -207,6 +239,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish,
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = lowFormat)
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -225,6 +258,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish,
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -243,6 +277,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English,
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -264,6 +299,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -284,6 +320,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -302,6 +339,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -320,6 +358,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||
@@ -340,6 +379,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
_remoteEpisode.Episodes.Add(_otherEpisode);
|
||||
@@ -354,6 +394,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
var remoteEpisodes = Builder<RemoteEpisode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(r => r.Series = _series)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.With(r => r.ParsedEpisodeInfo = new ParsedEpisodeInfo
|
||||
{
|
||||
Quality =
|
||||
@@ -387,6 +428,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -408,6 +450,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.English
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -429,6 +472,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode });
|
||||
@@ -449,6 +493,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Language = Language.Spanish
|
||||
})
|
||||
.With(r => r.Release = _releaseInfo)
|
||||
.With(r => r.CustomFormats = new List<CustomFormat>())
|
||||
.Build();
|
||||
|
||||
GivenQueue(new List<RemoteEpisode> { remoteEpisode }, TrackedDownloadState.FailedPending);
|
||||
|
||||
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.Download.Pending;
|
||||
@@ -93,7 +94,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
private void GivenUpgradeForExistingFile()
|
||||
{
|
||||
Mocker.GetMock<IUpgradableSpecification>()
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<QualityProfile>(), It.IsAny<LanguageProfile>(), It.IsAny<QualityModel>(), It.IsAny<Language>(), It.IsAny<int>(), It.IsAny<QualityModel>(), It.IsAny<Language>(), It.IsAny<int>()))
|
||||
.Setup(s => s.IsUpgradable(It.IsAny<QualityProfile>(), It.IsAny<LanguageProfile>(), It.IsAny<QualityModel>(), It.IsAny<Language>(), It.IsAny<List<CustomFormat>>(), It.IsAny<QualityModel>(), It.IsAny<Language>(), It.IsAny<List<CustomFormat>>()))
|
||||
.Returns(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
|
||||
using NzbDrone.Core.History;
|
||||
@@ -14,6 +15,7 @@ using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.CustomFormats;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Test.Languages;
|
||||
using NzbDrone.Core.Tv;
|
||||
@@ -40,6 +42,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<HistorySpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var doubleEpisodeList = new List<Episode>
|
||||
{
|
||||
@@ -53,6 +57,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
MinFormatScore = 0,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
})
|
||||
.With(l => l.LanguageProfile = new LanguageProfile
|
||||
@@ -67,14 +73,16 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English },
|
||||
Episodes = doubleEpisodeList
|
||||
Episodes = doubleEpisodeList,
|
||||
CustomFormats = new List<CustomFormat>()
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = _fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English },
|
||||
Episodes = singleEpisodeList
|
||||
Episodes = singleEpisodeList,
|
||||
CustomFormats = new List<CustomFormat>()
|
||||
};
|
||||
|
||||
_upgradableQuality = new Tuple<QualityModel, Language>(new QualityModel(Quality.SDTV, new Revision(version: 1)), Language.English);
|
||||
@@ -84,6 +92,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(s => s.EnableCompletedDownloadHandling)
|
||||
.Returns(true);
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<EpisodeHistory>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
private void GivenMostRecentForEpisode(int episodeId, string downloadId, Tuple<QualityModel, Language> quality, DateTime date, EpisodeHistoryEventType eventType)
|
||||
|
||||
@@ -4,6 +4,7 @@ using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Languages;
|
||||
@@ -12,6 +13,7 @@ using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
using NzbDrone.Core.Profiles.Qualities;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.CustomFormats;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@@ -34,6 +36,8 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.Resolve<UpgradableSpecification>();
|
||||
_upgradeDisk = Mocker.Resolve<UpgradeDiskSpecification>();
|
||||
|
||||
CustomFormatsFixture.GivenCustomFormats();
|
||||
|
||||
_firstFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now, Language = Language.English };
|
||||
_secondFile = new EpisodeFile { Quality = new QualityModel(Quality.Bluray1080p, new Revision(version: 2)), DateAdded = DateTime.Now, Language = Language.English };
|
||||
|
||||
@@ -47,7 +51,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
UpgradeAllowed = true,
|
||||
Cutoff = Quality.Bluray1080p.Id,
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities()
|
||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||
FormatItems = CustomFormatsFixture.GetSampleFormatItems("None"),
|
||||
MinFormatScore = 0,
|
||||
})
|
||||
.With(l => l.LanguageProfile = new LanguageProfile
|
||||
{
|
||||
@@ -61,15 +67,21 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English },
|
||||
Episodes = doubleEpisodeList
|
||||
Episodes = doubleEpisodeList,
|
||||
CustomFormats = new List<CustomFormat>()
|
||||
};
|
||||
|
||||
_parseResultSingle = new RemoteEpisode
|
||||
{
|
||||
Series = fakeSeries,
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English },
|
||||
Episodes = singleEpisodeList
|
||||
Episodes = singleEpisodeList,
|
||||
CustomFormats = new List<CustomFormat>()
|
||||
};
|
||||
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(x => x.ParseCustomFormat(It.IsAny<EpisodeFile>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
private void WithFirstFileUpgradable()
|
||||
@@ -143,11 +155,11 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_revision_downgrade_and_preferred_word_upgrade_if_propers_are_preferred()
|
||||
{
|
||||
Mocker.GetMock<IEpisodeFilePreferredWordCalculator>()
|
||||
.Setup(s => s.Calculate(It.IsAny<Series>(), It.IsAny<EpisodeFile>()))
|
||||
.Returns(5);
|
||||
Mocker.GetMock<ICustomFormatCalculationService>()
|
||||
.Setup(s => s.ParseCustomFormat(It.IsAny<EpisodeFile>()))
|
||||
.Returns(new List<CustomFormat>());
|
||||
|
||||
_parseResultSingle.PreferredWordScore = 10;
|
||||
_parseResultSingle.CustomFormatScore = 10;
|
||||
|
||||
_firstFile.Quality = new QualityModel(Quality.WEBDL1080p, new Revision(2));
|
||||
_parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.WEBDL1080p);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Profiles.Languages;
|
||||
@@ -36,8 +38,6 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
new object[] { Quality.WEBDL720p, 1, Language.Spanish, Quality.HDTV720p, 2, Language.French, Quality.WEBDL720p, Language.Spanish, false }
|
||||
};
|
||||
|
||||
private static readonly int NoPreferredWordScore = 0;
|
||||
|
||||
private void GivenAutoDownloadPropers(ProperDownloadTypes type)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>()
|
||||
@@ -69,10 +69,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
langProfile,
|
||||
new QualityModel(current, new Revision(version: currentVersion)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(newQuality, new Revision(version: newVersion)),
|
||||
Language.English,
|
||||
NoPreferredWordScore)
|
||||
new List<CustomFormat>())
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
langProfile,
|
||||
new QualityModel(current, new Revision(version: currentVersion)),
|
||||
currentLanguage,
|
||||
NoPreferredWordScore,
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(newQuality, new Revision(version: newVersion)),
|
||||
newLanguage,
|
||||
NoPreferredWordScore)
|
||||
new List<CustomFormat>())
|
||||
.Should().Be(expected);
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
langProfile,
|
||||
new QualityModel(Quality.DVD, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(Quality.DVD, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore)
|
||||
new List<CustomFormat>())
|
||||
.Should().BeTrue();
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
langProfile,
|
||||
new QualityModel(Quality.DVD, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(Quality.DVD, new Revision(version: 2)),
|
||||
Language.English,
|
||||
NoPreferredWordScore)
|
||||
new List<CustomFormat>())
|
||||
.Should().BeFalse();
|
||||
}
|
||||
|
||||
@@ -183,10 +183,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
langProfile,
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore,
|
||||
new List<CustomFormat>(),
|
||||
new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
|
||||
Language.English,
|
||||
NoPreferredWordScore)
|
||||
new List<CustomFormat>())
|
||||
.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user