mirror of
https://github.com/Radarr/Radarr
synced 2024-12-26 09:49:00 +00:00
Initial quality is only setup if no other quality profiles exists.
This commit is contained in:
parent
452b5c8f84
commit
edf9d1d2cc
2 changed files with 50 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
||||||
// ReSharper disable RedundantUsingDirective
|
// ReSharper disable RedundantUsingDirective
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using AutoMoq;
|
using AutoMoq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
@ -73,7 +74,7 @@ public void Update_Success()
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
var db = MockLib.GetEmptyDatabase();
|
var db = MockLib.GetEmptyDatabase();
|
||||||
mocker.SetConstant(db);
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
var testProfile = new QualityProfile
|
var testProfile = new QualityProfile
|
||||||
{
|
{
|
||||||
Name = Guid.NewGuid().ToString(),
|
Name = Guid.NewGuid().ToString(),
|
||||||
|
@ -95,7 +96,7 @@ public void Update_Success()
|
||||||
updated.Name.Should().Be(currentProfile.Name);
|
updated.Name.Should().Be(currentProfile.Name);
|
||||||
updated.Cutoff.Should().Be(QualityTypes.Bluray720p);
|
updated.Cutoff.Should().Be(QualityTypes.Bluray720p);
|
||||||
updated.AllowedString.Should().Be(currentProfile.AllowedString);
|
updated.AllowedString.Should().Be(currentProfile.AllowedString);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -127,5 +128,47 @@ public void Test_Series_Quality()
|
||||||
Assert.AreEqual(profileId, result[0].QualityProfileId);
|
Assert.AreEqual(profileId, result[0].QualityProfileId);
|
||||||
Assert.AreEqual(testProfile.Name, profile.Name);
|
Assert.AreEqual(testProfile.Name, profile.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetupInitial_should_add_two_profiles()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var profiles = mocker.Resolve<QualityProvider>().GetAllProfiles();
|
||||||
|
|
||||||
|
|
||||||
|
profiles.Should().HaveCount(2);
|
||||||
|
profiles.Should().Contain(e => e.Name == "HD");
|
||||||
|
profiles.Should().Contain(e => e.Name == "SD");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
//This confirms that new profiles are added only if no other profiles exists.
|
||||||
|
//We don't want to keep adding them back if a user deleted them on purpose.
|
||||||
|
public void SetupInitial_should_skip_if_any_profile_exists()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
var fakeProfile = Builder<QualityProfile>.CreateNew().Build();
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.Resolve<QualityProvider>().Add(fakeProfile);
|
||||||
|
mocker.Resolve<QualityProvider>().SetupDefaultProfiles();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
var profiles = mocker.Resolve<QualityProvider>().GetAllProfiles();
|
||||||
|
|
||||||
|
|
||||||
|
profiles.Should().HaveCount(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,9 +58,10 @@ public virtual QualityProfile Get(int profileId)
|
||||||
|
|
||||||
public virtual void SetupDefaultProfiles()
|
public virtual void SetupDefaultProfiles()
|
||||||
{
|
{
|
||||||
Logger.Info("Setting up default quality profiles");
|
if (GetAllProfiles().Count != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
var profiles = GetAllProfiles();
|
Logger.Info("Setting up default quality profiles");
|
||||||
|
|
||||||
var sd = new QualityProfile { Name = "SD", Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV };
|
var sd = new QualityProfile { Name = "SD", Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }, Cutoff = QualityTypes.SDTV };
|
||||||
|
|
||||||
|
@ -71,23 +72,9 @@ public virtual void SetupDefaultProfiles()
|
||||||
Cutoff = QualityTypes.HDTV
|
Cutoff = QualityTypes.HDTV
|
||||||
};
|
};
|
||||||
|
|
||||||
//Add or Update SD
|
Add(sd);
|
||||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", sd.Name));
|
Add(hd);
|
||||||
var sdDb = profiles.Where(p => p.Name == sd.Name).FirstOrDefault();
|
|
||||||
if (sdDb == null)
|
|
||||||
{
|
|
||||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", sd.Name));
|
|
||||||
Add(sd);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add or Update HD
|
|
||||||
Logger.Debug(String.Format("Checking for default QualityProfile: {0}", hd.Name));
|
|
||||||
var hdDb = profiles.Where(p => p.Name == hd.Name).FirstOrDefault();
|
|
||||||
if (hdDb == null)
|
|
||||||
{
|
|
||||||
Logger.Debug(String.Format("Adding new default QualityProfile: {0}", hd.Name));
|
|
||||||
Add(hd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue