mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 17:27:59 +00:00
fixed AllowedReleaseGroupSpecification
This commit is contained in:
parent
a4d69cc5ce
commit
67995a5cf6
4 changed files with 21 additions and 17 deletions
|
@ -1,5 +1,6 @@
|
|||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
@ -7,7 +8,6 @@
|
|||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class AllowedReleaseGroupSpecificationFixture : CoreTest<AllowedReleaseGroupSpecification>
|
||||
{
|
||||
private RemoteEpisode _parseResult;
|
||||
|
@ -27,6 +27,7 @@ public void Setup()
|
|||
[Test]
|
||||
public void should_be_true_when_allowedReleaseGroups_is_empty()
|
||||
{
|
||||
|
||||
Subject.IsSatisfiedBy(_parseResult).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
@ -36,15 +37,21 @@ public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup()
|
|||
Subject.IsSatisfiedBy(_parseResult).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup()
|
||||
[TestCase("2HD")]
|
||||
[TestCase("2hd")]
|
||||
[TestCase("other, 2hd, next")]
|
||||
[TestCase("other,2hd,next")]
|
||||
[TestCase("other,2hd,next,")]
|
||||
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup(string allowedList)
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.AllowedReleaseGroups).Returns(allowedList);
|
||||
Subject.IsSatisfiedBy(_parseResult).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(c => c.AllowedReleaseGroups).Returns("other");
|
||||
Subject.IsSatisfiedBy(_parseResult).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -479,6 +479,12 @@ public string NzbRestrictions
|
|||
set { SetValue("NzbRestrictions", value); }
|
||||
}
|
||||
|
||||
public string AllowedReleaseGroups
|
||||
{
|
||||
get { return GetValue("AllowedReleaseGroups", String.Empty); }
|
||||
set { SetValue("AllowedReleaseGroups", value); }
|
||||
}
|
||||
|
||||
private string GetValue(string key)
|
||||
{
|
||||
return GetValue(key, String.Empty);
|
||||
|
|
|
@ -78,6 +78,7 @@ public interface IConfigService
|
|||
PriorityType NzbgetBacklogTvPriority { get; set; }
|
||||
PriorityType NzbgetRecentTvPriority { get; set; }
|
||||
string NzbRestrictions { get; set; }
|
||||
string AllowedReleaseGroups { get; set; }
|
||||
string GetValue(string key, object defaultValue, bool persist = false);
|
||||
void SetValue(string key, string value);
|
||||
void SaveValues(Dictionary<string, object> configValues);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Model;
|
||||
|
@ -33,25 +34,14 @@ public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
|||
|
||||
//Todo: Make this use NzbRestrictions - How should whitelist be used? Will it override blacklist or vice-versa?
|
||||
|
||||
//var allowed = _configService.AllowedReleaseGroups;
|
||||
const string allowed = "";
|
||||
var allowed = _configService.AllowedReleaseGroups;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(allowed))
|
||||
return true;
|
||||
|
||||
var releaseGroup = subject.Report.ReleaseGroup;
|
||||
var reportReleaseGroup = subject.Report.ReleaseGroup.ToLower();
|
||||
|
||||
foreach (var group in allowed.Trim(',', ' ').Split(','))
|
||||
{
|
||||
if (releaseGroup.Equals(group.Trim(' '), StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
_logger.Trace("Item: {0}'s release group is wanted: {1}", subject, releaseGroup);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_logger.Trace("Item: {0}'s release group is not wanted: {1}", subject, releaseGroup);
|
||||
return false;
|
||||
return allowed.ToLower().Split(',').Any(allowedGroup => allowedGroup.Trim() == reportReleaseGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue