mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
Merge branch 'master' into userdb-efcore
# Conflicts: # Emby.Server.Implementations/Data/SqliteUserDataRepository.cs # Emby.Server.Implementations/Library/UserManager.cs # Jellyfin.Data/Entities/User.cs # Jellyfin.Data/ISavingChanges.cs # Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj # Jellyfin.Server.Implementations/JellyfinDb.cs # Jellyfin.Server/Migrations/MigrationRunner.cs # MediaBrowser.Model/Notifications/NotificationOptions.cs # MediaBrowser.sln
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
using Emby.Naming.Common;
|
||||
using Emby.Naming.Video;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public abstract class BaseVideoTest
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
protected VideoResolver GetParser()
|
||||
=> new VideoResolver(_namingOptions);
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
[InlineData("Maximum Ride - 2016 - WEBDL-1080p - x264 AC3.mkv", "Maximum Ride", 2016)]
|
||||
// FIXME: [InlineData("Robin Hood [Multi-Subs] [2018].mkv", "Robin Hood", 2018)]
|
||||
[InlineData(@"3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014)] // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
|
||||
[InlineData("3 days to kill (2005).mkv", "3 days to kill", 2005)]
|
||||
public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
|
||||
{
|
||||
input = Path.GetFileName(input);
|
||||
|
||||
@@ -5,7 +5,7 @@ using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class ExtraTests : BaseVideoTest
|
||||
public class ExtraTests
|
||||
{
|
||||
private readonly NamingOptions _videoOptions = new NamingOptions();
|
||||
|
||||
|
||||
@@ -4,26 +4,26 @@ using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class Format3DTests : BaseVideoTest
|
||||
public class Format3DTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Fact]
|
||||
public void TestKodiFormat3D()
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
Test("Super movie.3d.mp4", false, null, options);
|
||||
Test("Super movie.3d.hsbs.mp4", true, "hsbs", options);
|
||||
Test("Super movie.3d.sbs.mp4", true, "sbs", options);
|
||||
Test("Super movie.3d.htab.mp4", true, "htab", options);
|
||||
Test("Super movie.3d.tab.mp4", true, "tab", options);
|
||||
Test("Super movie 3d hsbs.mp4", true, "hsbs", options);
|
||||
Test("Super movie.3d.mp4", false, null);
|
||||
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
|
||||
Test("Super movie.3d.sbs.mp4", true, "sbs");
|
||||
Test("Super movie.3d.htab.mp4", true, "htab");
|
||||
Test("Super movie.3d.tab.mp4", true, "tab");
|
||||
Test("Super movie 3d hsbs.mp4", true, "hsbs");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test3DName()
|
||||
{
|
||||
var result =
|
||||
GetParser().ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv");
|
||||
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv");
|
||||
|
||||
Assert.Equal("hsbs", result.Format3D);
|
||||
Assert.Equal("Oblivion", result.Name);
|
||||
@@ -34,32 +34,31 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
// These were introduced for Media Browser 3
|
||||
// Kodi conventions are preferred but these still need to be supported
|
||||
var options = new NamingOptions();
|
||||
|
||||
Test("Super movie.3d.mp4", false, null, options);
|
||||
Test("Super movie.3d.hsbs.mp4", true, "hsbs", options);
|
||||
Test("Super movie.3d.sbs.mp4", true, "sbs", options);
|
||||
Test("Super movie.3d.htab.mp4", true, "htab", options);
|
||||
Test("Super movie.3d.tab.mp4", true, "tab", options);
|
||||
Test("Super movie.3d.mp4", false, null);
|
||||
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
|
||||
Test("Super movie.3d.sbs.mp4", true, "sbs");
|
||||
Test("Super movie.3d.htab.mp4", true, "htab");
|
||||
Test("Super movie.3d.tab.mp4", true, "tab");
|
||||
|
||||
Test("Super movie.hsbs.mp4", true, "hsbs", options);
|
||||
Test("Super movie.sbs.mp4", true, "sbs", options);
|
||||
Test("Super movie.htab.mp4", true, "htab", options);
|
||||
Test("Super movie.tab.mp4", true, "tab", options);
|
||||
Test("Super movie.sbs3d.mp4", true, "sbs3d", options);
|
||||
Test("Super movie.3d.mvc.mp4", true, "mvc", options);
|
||||
Test("Super movie.hsbs.mp4", true, "hsbs");
|
||||
Test("Super movie.sbs.mp4", true, "sbs");
|
||||
Test("Super movie.htab.mp4", true, "htab");
|
||||
Test("Super movie.tab.mp4", true, "tab");
|
||||
Test("Super movie.sbs3d.mp4", true, "sbs3d");
|
||||
Test("Super movie.3d.mvc.mp4", true, "mvc");
|
||||
|
||||
Test("Super movie [3d].mp4", false, null, options);
|
||||
Test("Super movie [hsbs].mp4", true, "hsbs", options);
|
||||
Test("Super movie [fsbs].mp4", true, "fsbs", options);
|
||||
Test("Super movie [ftab].mp4", true, "ftab", options);
|
||||
Test("Super movie [htab].mp4", true, "htab", options);
|
||||
Test("Super movie [sbs3d].mp4", true, "sbs3d", options);
|
||||
Test("Super movie [3d].mp4", false, null);
|
||||
Test("Super movie [hsbs].mp4", true, "hsbs");
|
||||
Test("Super movie [fsbs].mp4", true, "fsbs");
|
||||
Test("Super movie [ftab].mp4", true, "ftab");
|
||||
Test("Super movie [htab].mp4", true, "htab");
|
||||
Test("Super movie [sbs3d].mp4", true, "sbs3d");
|
||||
}
|
||||
|
||||
private void Test(string input, bool is3D, string format3D, NamingOptions options)
|
||||
private void Test(string input, bool is3D, string? format3D)
|
||||
{
|
||||
var parser = new Format3DParser(options);
|
||||
var parser = new Format3DParser(_namingOptions);
|
||||
|
||||
var result = parser.Parse(input);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class MultiVersionTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestMultiEdition1()
|
||||
@@ -430,8 +432,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
|
||||
private VideoListResolver GetResolver()
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
return new VideoListResolver(options);
|
||||
return new VideoListResolver(_namingOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class StackTests : BaseVideoTest
|
||||
public class StackTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Fact]
|
||||
public void TestSimpleStack()
|
||||
{
|
||||
@@ -446,7 +448,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
|
||||
private StackResolver GetResolver()
|
||||
{
|
||||
return new StackResolver(new NamingOptions());
|
||||
return new StackResolver(_namingOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class StubTests : BaseVideoTest
|
||||
public class StubTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Fact]
|
||||
public void TestStubs()
|
||||
{
|
||||
@@ -27,16 +29,14 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
public void TestStubName()
|
||||
{
|
||||
var result =
|
||||
GetParser().ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc");
|
||||
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc");
|
||||
|
||||
Assert.Equal("Oblivion", result.Name);
|
||||
}
|
||||
|
||||
private void Test(string path, bool isStub, string stubType)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var isStubResult = StubResolver.TryResolveFile(path, options, out var stubTypeResult);
|
||||
var isStubResult = StubResolver.TryResolveFile(path, _namingOptions, out var stubTypeResult);
|
||||
|
||||
Assert.Equal(isStub, isStubResult);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class VideoListResolverTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestStackAndExtras()
|
||||
@@ -450,8 +451,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||
|
||||
private VideoListResolver GetResolver()
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
return new VideoListResolver(options);
|
||||
return new VideoListResolver(_namingOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,275 +1,200 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using Emby.Naming.Common;
|
||||
using Emby.Naming.Video;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.Video
|
||||
{
|
||||
public class VideoResolverTests : BaseVideoTest
|
||||
public class VideoResolverTests
|
||||
{
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestSimpleFile()
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
public static IEnumerable<object[]> GetResolveFileTestData()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006).mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("Brave", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
|
||||
Container = "mkv",
|
||||
Name = "7 Psychos"
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
|
||||
Container = "mkv",
|
||||
Name = "3 days to kill",
|
||||
Year = 2005
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
|
||||
Container = "mkv",
|
||||
Name = "American.Psycho",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
|
||||
Container = "mkv",
|
||||
Name = "brave",
|
||||
Year = 2006,
|
||||
Is3D = true,
|
||||
Format3D = "sbs",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
|
||||
Container = "mkv",
|
||||
Name = "300",
|
||||
Year = 2006
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
|
||||
Container = "mkv",
|
||||
Name = "300",
|
||||
Year = 2006,
|
||||
Is3D = true,
|
||||
Format3D = "sbs",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
|
||||
Container = "disc",
|
||||
Name = "brave",
|
||||
Year = 2006,
|
||||
IsStub = true,
|
||||
StubType = "bluray",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
|
||||
Container = "disc",
|
||||
Name = "300",
|
||||
Year = 2006,
|
||||
IsStub = true,
|
||||
StubType = "bluray",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
|
||||
Container = "disc",
|
||||
Name = "Brave",
|
||||
Year = 2006,
|
||||
IsStub = true,
|
||||
StubType = "bluray",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
|
||||
Container = "disc",
|
||||
Name = "300",
|
||||
Year = 2006,
|
||||
IsStub = true,
|
||||
StubType = "bluray",
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
|
||||
Container = "mkv",
|
||||
Name = "300",
|
||||
Year = 2006,
|
||||
ExtraType = ExtraType.Trailer,
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
|
||||
Container = "mkv",
|
||||
Name = "Brave",
|
||||
Year = 2006,
|
||||
ExtraType = ExtraType.Trailer,
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
|
||||
Container = "mkv",
|
||||
Name = "300",
|
||||
Year = 2006
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
|
||||
Container = "mkv",
|
||||
Name = "Bad Boys",
|
||||
Year = 1995,
|
||||
}
|
||||
};
|
||||
yield return new object[]
|
||||
{
|
||||
new VideoFileInfo()
|
||||
{
|
||||
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
|
||||
Container = "mkv",
|
||||
Name = "Brave",
|
||||
Year = 2006,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestSimpleFile2()
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetResolveFileTestData))]
|
||||
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
|
||||
{
|
||||
var parser = GetParser();
|
||||
var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path);
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv");
|
||||
|
||||
Assert.Equal(1995, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("Bad Boys", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestSimpleFileWithNumericName()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("300", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestExtra()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal(ExtraType.Trailer, result.ExtraType);
|
||||
Assert.Equal("Brave (2006)-trailer", result.Name);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestExtraWithNumericName()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006)-trailer.mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("300 (2006)-trailer", result.Name);
|
||||
Assert.Equal(ExtraType.Trailer, result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestStubFileWithNumericName()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).bluray.disc");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.True(result.IsStub);
|
||||
Assert.Equal("bluray", result.StubType);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("300", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestStubFile()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006).bluray.disc");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.True(result.IsStub);
|
||||
Assert.Equal("bluray", result.StubType);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("Brave", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestExtraStubWithNumericNameNotSupported()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.True(result.IsStub);
|
||||
Assert.Equal("bluray", result.StubType);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("300", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestExtraStubNotSupported()
|
||||
{
|
||||
// Using a stub for an extra is currently not supported
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.True(result.IsStub);
|
||||
Assert.Equal("bluray", result.StubType);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("brave", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void Test3DFileWithNumericName()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.True(result.Is3D);
|
||||
Assert.Equal("sbs", result.Format3D);
|
||||
Assert.Equal("300", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestBad3DFileWithNumericName()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("300", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
Assert.Null(result.Format3D);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void Test3DFile()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv");
|
||||
|
||||
Assert.Equal(2006, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.True(result.Is3D);
|
||||
Assert.Equal("sbs", result.Format3D);
|
||||
Assert.Equal("brave", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestNameWithoutDate()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/American Psycho/American.Psycho.mkv");
|
||||
|
||||
Assert.Null(result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Null(result.Format3D);
|
||||
Assert.Equal("American.Psycho", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestCleanDateAndStringsSequence()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
// In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/3.Days.to.Kill/3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv");
|
||||
|
||||
Assert.Equal(2014, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Null(result.Format3D);
|
||||
Assert.Equal("3.Days.to.Kill", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
// [Fact]
|
||||
public void TestCleanDateAndStringsSequence1()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
// In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv");
|
||||
|
||||
Assert.Equal(2005, result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Null(result.Format3D);
|
||||
Assert.Equal("3 days to kill", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFolderNameWithExtension()
|
||||
{
|
||||
var parser = GetParser();
|
||||
|
||||
var result =
|
||||
parser.ResolveFile(@"/server/Movies/7 Psychos.mkv/7 Psychos.mkv");
|
||||
|
||||
Assert.Null(result.Year);
|
||||
Assert.False(result.IsStub);
|
||||
Assert.False(result.Is3D);
|
||||
Assert.Equal("7 Psychos", result.Name);
|
||||
Assert.Null(result.ExtraType);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(result.Path, expectedResult.Path);
|
||||
Assert.Equal(result.Container, expectedResult.Container);
|
||||
Assert.Equal(result.Name, expectedResult.Name);
|
||||
Assert.Equal(result.Year, expectedResult.Year);
|
||||
Assert.Equal(result.ExtraType, expectedResult.ExtraType);
|
||||
Assert.Equal(result.Format3D, expectedResult.Format3D);
|
||||
Assert.Equal(result.Is3D, expectedResult.Is3D);
|
||||
Assert.Equal(result.IsStub, expectedResult.IsStub);
|
||||
Assert.Equal(result.StubType, expectedResult.StubType);
|
||||
Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
|
||||
Assert.Equal(result.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
tests/MediaBrowser.Api.Tests/BrandingServiceTests.cs
Normal file
49
tests/MediaBrowser.Api.Tests/BrandingServiceTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Branding;
|
||||
using Xunit;
|
||||
|
||||
namespace MediaBrowser.Api.Tests
|
||||
{
|
||||
public sealed class BrandingServiceTests : IClassFixture<JellyfinApplicationFactory>
|
||||
{
|
||||
private readonly JellyfinApplicationFactory _factory;
|
||||
|
||||
public BrandingServiceTests(JellyfinApplicationFactory factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetConfiguration_ReturnsCorrectResponse()
|
||||
{
|
||||
// Arrange
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("/Branding/Configuration");
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString());
|
||||
var responseBody = await response.Content.ReadAsStreamAsync();
|
||||
_ = await JsonSerializer.DeserializeAsync<BrandingOptions>(responseBody);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/Branding/Css")]
|
||||
[InlineData("/Branding/Css.css")]
|
||||
public async Task GetCss_ReturnsCorrectResponse(string url)
|
||||
{
|
||||
// Arrange
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync(url);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode();
|
||||
Assert.Equal("text/css", response.Content.Headers.ContentType.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
120
tests/MediaBrowser.Api.Tests/JellyfinApplicationFactory.cs
Normal file
120
tests/MediaBrowser.Api.Tests/JellyfinApplicationFactory.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using Emby.Server.Implementations;
|
||||
using Emby.Server.Implementations.IO;
|
||||
using Emby.Server.Implementations.Networking;
|
||||
using Jellyfin.Drawing.Skia;
|
||||
using Jellyfin.Server;
|
||||
using MediaBrowser.Common;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Factory for bootstrapping the Jellyfin application in memory for functional end to end tests.
|
||||
/// </summary>
|
||||
public class JellyfinApplicationFactory : WebApplicationFactory<Startup>
|
||||
{
|
||||
private static readonly string _testPathRoot = Path.Combine(Path.GetTempPath(), "jellyfin-test-data");
|
||||
private static readonly ConcurrentBag<IDisposable> _disposableComponents = new ConcurrentBag<IDisposable>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="JellyfinApplicationFactory"/> class.
|
||||
/// </summary>
|
||||
public JellyfinApplicationFactory()
|
||||
{
|
||||
// Perform static initialization that only needs to happen once per test-run
|
||||
Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
|
||||
Program.PerformStaticInitialization();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override IWebHostBuilder CreateWebHostBuilder()
|
||||
{
|
||||
return new WebHostBuilder();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||
{
|
||||
// Specify the startup command line options
|
||||
var commandLineOpts = new StartupOptions
|
||||
{
|
||||
NoWebClient = true,
|
||||
NoAutoRunWebApp = true
|
||||
};
|
||||
|
||||
// Use a temporary directory for the application paths
|
||||
var webHostPathRoot = Path.Combine(_testPathRoot, "test-host-" + Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
|
||||
Directory.CreateDirectory(Path.Combine(webHostPathRoot, "logs"));
|
||||
Directory.CreateDirectory(Path.Combine(webHostPathRoot, "config"));
|
||||
Directory.CreateDirectory(Path.Combine(webHostPathRoot, "cache"));
|
||||
Directory.CreateDirectory(Path.Combine(webHostPathRoot, "jellyfin-web"));
|
||||
var appPaths = new ServerApplicationPaths(
|
||||
webHostPathRoot,
|
||||
Path.Combine(webHostPathRoot, "logs"),
|
||||
Path.Combine(webHostPathRoot, "config"),
|
||||
Path.Combine(webHostPathRoot, "cache"),
|
||||
Path.Combine(webHostPathRoot, "jellyfin-web"));
|
||||
|
||||
// Create the logging config file
|
||||
// TODO: We shouldn't need to do this since we are only logging to console
|
||||
Program.InitLoggingConfigFile(appPaths).GetAwaiter().GetResult();
|
||||
|
||||
// Create a copy of the application configuration to use for startup
|
||||
var startupConfig = Program.CreateAppConfiguration(commandLineOpts, appPaths);
|
||||
|
||||
ILoggerFactory loggerFactory = new SerilogLoggerFactory();
|
||||
_disposableComponents.Add(loggerFactory);
|
||||
|
||||
// Create the app host and initialize it
|
||||
var appHost = new CoreAppHost(
|
||||
appPaths,
|
||||
loggerFactory,
|
||||
commandLineOpts,
|
||||
new ManagedFileSystem(loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
|
||||
new NetworkManager(loggerFactory.CreateLogger<NetworkManager>()));
|
||||
_disposableComponents.Add(appHost);
|
||||
var serviceCollection = new ServiceCollection();
|
||||
appHost.Init(serviceCollection);
|
||||
|
||||
// Configure the web host builder
|
||||
Program.ConfigureWebHostBuilder(builder, appHost, serviceCollection, commandLineOpts, startupConfig, appPaths);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override TestServer CreateServer(IWebHostBuilder builder)
|
||||
{
|
||||
// Create the test server using the base implementation
|
||||
var testServer = base.CreateServer(builder);
|
||||
|
||||
// Finish initializing the app host
|
||||
var appHost = (CoreAppHost)testServer.Services.GetRequiredService<IApplicationHost>();
|
||||
appHost.ServiceProvider = testServer.Services;
|
||||
appHost.InitializeServices().GetAwaiter().GetResult();
|
||||
appHost.RunStartupTasksAsync().GetAwaiter().GetResult();
|
||||
|
||||
return testServer;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
foreach (var disposable in _disposableComponents)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
|
||||
_disposableComponents.Clear();
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
Normal file
33
tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Jellyfin.Server\Jellyfin.Server.csproj" />
|
||||
<ProjectReference Include="..\..\MediaBrowser.Api\MediaBrowser.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Code Analyzers-->
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
22
tests/jellyfin-tests.ruleset
Normal file
22
tests/jellyfin-tests.ruleset
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Rules for MediaBrowser.Api.Tests" Description="Code analysis rules for MediaBrowser.Api.Tests.csproj" ToolsVersion="14.0">
|
||||
|
||||
<!-- Include the solution default RuleSet. The rules in this file will override the defaults. -->
|
||||
<Include Path="../jellyfin.ruleset" Action="Default" />
|
||||
|
||||
<!-- StyleCop Analyzer Rules -->
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||
<!-- SA0001: XML comment analysis is disabled due to project configuration -->
|
||||
<Rule Id="SA0001" Action="None" />
|
||||
</Rules>
|
||||
|
||||
<!-- FxCop Analyzer Rules -->
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.Design">
|
||||
<!-- CA1707: Identifiers should not contain underscores -->
|
||||
<Rule Id="CA1707" Action="None" />
|
||||
<!-- CA2007: Consider calling ConfigureAwait on the awaited task -->
|
||||
<Rule Id="CA2007" Action="None" />
|
||||
<!-- CA2234: Pass system uri objects instead of strings -->
|
||||
<Rule Id="CA2234" Action="Info" />
|
||||
</Rules>
|
||||
</RuleSet>
|
||||
Reference in New Issue
Block a user