Files
Libation/Source/_Tests/LibationCli.Tests/DeferredRetryOptionsTests.cs
T
Cursor Agentandrmcrackan f0d344099a fix(scan): keep a book's supplement in step with what the last scan says
Only a newly imported book ever recorded a supplement, so a title that gained a
PDF after its first import never got one, and a title that lost its PDF went on
claiming one - which in issue #1973 is why three titles Audible has no PDF for
were still being asked for.

Sync from updateBook as well, and give Book set-semantics for the one supplement
Audible reports per title. The duplicate guard compared the incoming url to
itself, so it happened to mean 'this book already has a supplement' and a url
that had changed was silently ignored.

A supplement is dropped only when Audible says outright that no supplement url is
available. A missing url says nothing by itself: episodes come from the catalog,
which is never asked for pdf_url, so there it means 'not asked'. A PDF already
downloaded is left alone either way, since the file is on disk and the library
should go on saying so.

Co-authored-by: rmcrackan <rmcrackan@gmail.com>
2026-08-19 18:36:02 +00:00

47 lines
1.6 KiB
C#

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
namespace LibationCli.Tests;
/// <summary>
/// Which liberate runs leave alone the titles Audible recently refused. A run that says what it wants
/// downloaded must always attempt it.
/// </summary>
[TestClass]
public class DeferredRetryOptionsTests
{
private static OptionsBase? Parse(params string[] args)
{
using var error = new StringWriter();
return Program.ParseInvocation(args, error).Result?.Value as OptionsBase;
}
[TestMethod]
public void A_plain_liberate_run_waits_on_the_titles_Audible_refused()
=> Assert.IsTrue(((ProcessableOptionsBase)Parse("liberate")!).HonorsDeferredRetries);
[TestMethod]
[DataRow("--force")]
[DataRow("-f")]
public void Force_attempts_them_anyway(string force)
=> Assert.IsFalse(((ProcessableOptionsBase)Parse("liberate", force)!).HonorsDeferredRetries);
[TestMethod]
[DataRow("--pdf")]
[DataRow("-p")]
public void A_pdf_only_run_waits_on_them_as_well(string pdfOnly)
{
// A PDF comes from the same license request as the audiobook, so a title Libation is waiting on would be
// refused for its PDF exactly as it was for its audio. This run used to be exempt, which is how issue
// #1973's scheduled run kept asking.
Assert.IsTrue(((ProcessableOptionsBase)Parse("liberate", pdfOnly)!).HonorsDeferredRetries);
}
[TestMethod]
public void Other_processable_verbs_do_not_consult_the_record()
{
// convert-to-mp3 and the like never request a license, so there is nothing for them to wait on.
Assert.IsFalse(((ProcessableOptionsBase)Parse("convert")!).HonorsDeferredRetries);
}
}