aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2019-11-17 13:55:27 -0500
committerJoshua Boniface <joshua@boniface.me>2019-11-24 13:37:23 -0500
commit2de763eef9a46d77faf98801feff8fc335719eab (patch)
tree2b1026bc8f70844e6c81c7f8d750a2f936c12b2f
parent46ab046c344f036f5c0ceea410c39a8a540b67fc (diff)
Merge pull request #1992 from Bond-009/namingtests
Fix naming tests (cherry picked from commit 78e0afae2fba48212dab2986818b5156868592fb) Signed-off-by: Joshua Boniface <joshua@boniface.me>
-rw-r--r--Emby.Naming/Common/NamingOptions.cs15
-rw-r--r--Emby.Naming/Emby.Naming.csproj7
-rw-r--r--tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj2
-rw-r--r--tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs27
-rw-r--r--tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj9
5 files changed, 35 insertions, 25 deletions
diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs
index 9cf430daf..d37be0e63 100644
--- a/Emby.Naming/Common/NamingOptions.cs
+++ b/Emby.Naming/Common/NamingOptions.cs
@@ -311,6 +311,14 @@ namespace Emby.Naming.Common
}
},
+ // This isn't a Kodi naming rule, but the expression below causes false positives,
+ // so we make sure this one gets tested first.
+ // "Foo Bar 889"
+ new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?<seriesname>(\w+\s*?)*)\s(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$")
+ {
+ IsNamed = true
+ },
+
new EpisodeExpression("[\\\\/\\._ \\[\\(-]([0-9]+)x([0-9]+(?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([^\\\\/]*)$")
{
SupportsAbsoluteEpisodeNumbers = true
@@ -328,9 +336,10 @@ namespace Emby.Naming.Common
// *** End Kodi Standard Naming
-                // [bar] Foo - 1 [baz]
-                new EpisodeExpression(@".*?(\[.*?\])+.*?(?<seriesname>(\w+\s)+?)[-\s_]+(?<epnumber>\d+).*$"){
- IsNamed=false,
+                // [bar] Foo - 1 [baz]
+ new EpisodeExpression(@".*?(\[.*?\])+.*?(?<seriesname>(\w+\s*?)+?)[-\s_]+(?<epnumber>\d+).*$")
+ {
+ IsNamed = true
},
new EpisodeExpression(@".*(\\|\/)[sS]?(?<seasonnumber>\d+)[xX](?<epnumber>\d+)[^\\\/]*$")
{
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 0b1ce2fce..0e3bd3fac 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -23,9 +23,10 @@
<!-- Code analysers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
- <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" />
- <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
- <PackageReference Include="SerilogAnalyzer" Version="0.15.0" />
+ <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4" PrivateAssets="All" />
+ <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
+ <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
diff --git a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
index 9188b8a02..6e2aebf4e 100644
--- a/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
+++ b/tests/Jellyfin.Common.Tests/Jellyfin.Common.Tests.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="coverlet.collector" Version="1.1.0" />
diff --git a/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs b/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs
index 28ccd6df1..dd1e04215 100644
--- a/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs
+++ b/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs
@@ -1,8 +1,9 @@
-namespace Emby.Naming.TV
-{
- using Emby.Naming.Common;
- using Xunit;
+using Emby.Naming.Common;
+using Emby.Naming.TV;
+using Xunit;
+namespace Jellyfin.Naming.Tests
+{
public class EpisodePathParserTest
{
[Theory]
@@ -21,8 +22,8 @@ namespace Emby.Naming.TV
Assert.Equal(season, res.SeasonNumber);
Assert.Equal(episode, res.EpisodeNumber);
- //testing other paths delimeter
- var res2 = p.Parse(path.Replace("/", "\\"), false);
+ // testing other paths delimeter
+ var res2 = p.Parse(path.Replace('/', '\\'), false);
Assert.True(res2.Success);
Assert.Equal(name, res2.SeriesName);
Assert.Equal(season, res2.SeasonNumber);
@@ -31,24 +32,24 @@ namespace Emby.Naming.TV
[Theory]
[InlineData("/media/Foo/Foo 889", "Foo", 889)]
- [InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)]
+ [InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)]
public void ParseEpisodeWithoutSeason(string path, string name, int episode)
{
NamingOptions o = new NamingOptions();
EpisodePathParser p = new EpisodePathParser(o);
- var res = p.Parse(path, true, null, null, true);
+ var res = p.Parse(path, true, fillExtendedInfo: true);
Assert.True(res.Success);
Assert.Equal(name, res.SeriesName);
- Assert.True(res.SeasonNumber == null);
+ Assert.Null(res.SeasonNumber);
Assert.Equal(episode, res.EpisodeNumber);
- //testing other paths delimeter
- var res2 = p.Parse(path.Replace("/", "\\"), false, null, null, true);
+ // testing other paths delimeter
+ var res2 = p.Parse(path.Replace('/', '\\'), false, fillExtendedInfo: false);
Assert.True(res2.Success);
Assert.Equal(name, res2.SeriesName);
- Assert.True(res2.SeasonNumber == null);
+ Assert.Null(res2.SeasonNumber);
Assert.Equal(episode, res2.EpisodeNumber);
}
}
-} \ No newline at end of file
+}
diff --git a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
index f5e151348..fe1518131 100644
--- a/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
+++ b/tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
@@ -2,15 +2,14 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
-
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
- <PackageReference Include="xunit" Version="2.4.0" />
- <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
- <PackageReference Include="coverlet.collector" Version="1.0.1" />
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
+ <PackageReference Include="xunit" Version="2.4.1" />
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
+ <PackageReference Include="coverlet.collector" Version="1.1.0" />
</ItemGroup>
<ItemGroup>