mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
Merge branch 'qualitysize' into develop
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Datastore.Migration
|
||||
{
|
||||
[TestFixture]
|
||||
public class update_quality_minmax_size : MigrationTest<Core.Datastore.Migration.update_quality_minmax_size>
|
||||
{
|
||||
[Test]
|
||||
public void should_not_fail_if_empty()
|
||||
{
|
||||
WithTestDb(c =>
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
|
||||
|
||||
items.Should().HaveCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_set_rawhd_to_null()
|
||||
{
|
||||
WithTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("QualityDefinitions").Row(new
|
||||
{
|
||||
Quality = 1,
|
||||
Title = "SDTV",
|
||||
MinSize = 0,
|
||||
MaxSize = 100
|
||||
})
|
||||
.Row(new
|
||||
{
|
||||
Quality = 10,
|
||||
Title = "RawHD",
|
||||
MinSize = 0,
|
||||
MaxSize = 100
|
||||
});
|
||||
});
|
||||
|
||||
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
|
||||
|
||||
items.Should().HaveCount(2);
|
||||
|
||||
items.First(v => v.Quality.Id == 10).MaxSize.Should().NotHaveValue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_set_zero_maxsize_to_null()
|
||||
{
|
||||
WithTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("QualityDefinitions").Row(new
|
||||
{
|
||||
Quality = 1,
|
||||
Title = "SDTV",
|
||||
MinSize = 0,
|
||||
MaxSize = 0
|
||||
});
|
||||
});
|
||||
|
||||
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
|
||||
|
||||
items.Should().HaveCount(1);
|
||||
|
||||
items.First(v => v.Quality.Id == 1).MaxSize.Should().NotHaveValue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_preserve_values()
|
||||
{
|
||||
WithTestDb(c =>
|
||||
{
|
||||
c.Insert.IntoTable("QualityDefinitions").Row(new
|
||||
{
|
||||
Quality = 1,
|
||||
Title = "SDTV",
|
||||
MinSize = 0,
|
||||
MaxSize = 100
|
||||
})
|
||||
.Row(new
|
||||
{
|
||||
Quality = 10,
|
||||
Title = "RawHD",
|
||||
MinSize = 0,
|
||||
MaxSize = 100
|
||||
});
|
||||
});
|
||||
|
||||
var items = Mocker.Resolve<QualityDefinitionRepository>().All();
|
||||
|
||||
items.Should().HaveCount(2);
|
||||
|
||||
items.First(v => v.Quality.Id == 1).MaxSize.Should().Be(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
@@ -6,8 +7,8 @@ using NUnit.Framework;
|
||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
@@ -52,6 +53,10 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
|
||||
};
|
||||
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(It.IsAny<Quality>()))
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
|
||||
qualityType = Builder<QualityDefinition>.CreateNew()
|
||||
.With(q => q.MinSize = 2)
|
||||
.With(q => q.MaxSize = 10)
|
||||
@@ -144,7 +149,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
series.Runtime = 30;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = 18457280000;
|
||||
qualityType.MaxSize = 0;
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
@@ -157,9 +162,9 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
series.Runtime = 60;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Release.Size = 36857280000;
|
||||
qualityType.MaxSize = 0;
|
||||
qualityType.MaxSize = null;
|
||||
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue(); ;
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -180,12 +185,14 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
[Test]
|
||||
public void should_return_true_if_RAWHD()
|
||||
{
|
||||
var parseResult = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = new ParsedEpisodeInfo { Quality = new QualityModel(Quality.RAWHD) },
|
||||
};
|
||||
parseResultSingle.ParsedEpisodeInfo.Quality = new QualityModel(Quality.RAWHD);
|
||||
|
||||
series.Runtime = 45;
|
||||
parseResultSingle.Series = series;
|
||||
parseResultSingle.Series.SeriesType = SeriesTypes.Daily;
|
||||
parseResultSingle.Release.Size = 8000.Megabytes();
|
||||
|
||||
Subject.IsSatisfiedBy(parseResult, null).Accepted.Should().BeTrue();
|
||||
Subject.IsSatisfiedBy(parseResultSingle, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
<Compile Include="Datastore\Migration\074_disable_eztv.cs" />
|
||||
<Compile Include="Datastore\Migration\072_history_grabIdFixture.cs" />
|
||||
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />
|
||||
<Compile Include="Datastore\Migration\084_update_quality_minmax_sizeFixture.cs" />
|
||||
<Compile Include="Datastore\Migration\081_move_dot_prefix_to_transmission_categoryFixture.cs" />
|
||||
<Compile Include="Datastore\Migration\079_dedupe_tagsFixture.cs" />
|
||||
<Compile Include="Datastore\Migration\075_force_lib_updateFixture.cs" />
|
||||
|
||||
Reference in New Issue
Block a user