apisearch: parse season/episode only if it's at the end of the query (#14007)

This commit is contained in:
Bogdan
2023-02-13 12:31:37 +02:00
committed by GitHub
parent d7437f2a0f
commit eb63aecf8b
3 changed files with 65 additions and 26 deletions

View File

@@ -0,0 +1,32 @@
using Jackett.Common.Models.DTO;
using NUnit.Framework;
namespace Jackett.Test.Common.Models.DTO
{
[TestFixture]
public class ApiSearchTests
{
[TestCase("The.Good.Lord.S01E05.720p.WEB.H264-CAKES", "The.Good.Lord.S01E05.720p.WEB.H264-CAKES", 0, null)]
[TestCase("The.Good.Lord.S01E05.", "The.Good.Lord.S01E05.", 0, null)]
[TestCase("The.Good.Lord.S01E05", "The.Good.Lord. S01E05", 1, "5")]
[TestCase("The Good Lord S01E05", "The Good Lord S01E05", 1, "5")]
[TestCase("The Good Lord S01 E05", "The Good Lord S01E05", 1, "5")]
[TestCase("The Good Lord S01", "The Good Lord S01", 1, null)]
[TestCase("The Good Lord E05", "The Good Lord", 0, "5")]
[TestCase("The.Good.Lord.s01e05", "The.Good.Lord.s01e05", 0, null)]
[TestCase("The.Good.Lord.S01e05", "The.Good.Lord.S01e05", 0, null)]
[TestCase("The.Good.Lord.s01E05", "The.Good.Lord.s01E05", 0, null)]
[TestCase("The.Good.Lord.S1E5", "The.Good.Lord.S1E5", 0, null)]
[TestCase("The.Good.Lord.S11E5", "The.Good.Lord.S11E5", 0, null)]
[TestCase("The.Good.Lord.S1E15", "The.Good.Lord.S1E15", 0, null)]
public void TestToTorznabQuery(string query, string expected, int season, string episode)
{
var request = new ApiSearch { Query = query };
var currentQuery = ApiSearch.ToTorznabQuery(request);
Assert.AreEqual(expected, currentQuery.GetQueryString());
Assert.AreEqual(season, currentQuery.Season);
Assert.AreEqual(episode, currentQuery.Episode);
}
}
}