mirror of
https://github.com/Readarr/Readarr
synced 2025-12-14 20:36:18 +01:00
Fixed: Check for unexpected parent tags to fix GoodReads Series
This commit is contained in:
parent
a1ee6aa8ac
commit
fd08e9d2c4
2 changed files with 67 additions and 0 deletions
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using System.Xml.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.MetadataSource.Goodreads;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MetadataSource.Goodreads.Resources
|
||||
{
|
||||
[TestFixture]
|
||||
public class WorkResourceFixture : CoreTest<WorkResource>
|
||||
{
|
||||
[Test]
|
||||
public void parse_non_work()
|
||||
{
|
||||
XElement element = new XElement("Dummy", "entry");
|
||||
WorkResource work = new WorkResource();
|
||||
|
||||
Assert.Throws<NullReferenceException>(() => work.Parse(element));
|
||||
|
||||
work.OriginalTitle.Should().Be(null);
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void parse_minimal_work()
|
||||
{
|
||||
XElement element = new XElement("work",
|
||||
new XElement("original_title", "Book Title"),
|
||||
new XElement("id", "123456789"));
|
||||
|
||||
WorkResource work = new WorkResource();
|
||||
|
||||
work.Parse(element);
|
||||
|
||||
work.OriginalTitle.Should().Be("Book Title");
|
||||
work.Id.Should().Be(123456789);
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void parse_minimal_work_with_surrounding_tags()
|
||||
{
|
||||
XElement element = new XElement("series_works",
|
||||
new XElement("work",
|
||||
new XElement("original_title", "Book Title"),
|
||||
new XElement("id", "123456789")));
|
||||
|
||||
WorkResource work = new WorkResource();
|
||||
|
||||
work.Parse(element);
|
||||
|
||||
work.OriginalTitle.Should().Be("Book Title");
|
||||
work.Id.Should().Be(123456789);
|
||||
|
||||
ExceptionVerification.IgnoreWarns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -94,6 +94,11 @@ public sealed class WorkResource : GoodreadsResource
|
|||
|
||||
public override void Parse(XElement element)
|
||||
{
|
||||
if (element.AncestorsAndSelf().First().Name != "work")
|
||||
{
|
||||
element = element.Element("work");
|
||||
}
|
||||
|
||||
Id = element.ElementAsLong("id");
|
||||
|
||||
var bestBookElement = element.Element("best_book");
|
||||
|
|
|
|||
Loading…
Reference in a new issue