diff options
| author | Shadowghost <Shadowghost@users.noreply.github.com> | 2026-11-20 07:23:42 -0500 |
|---|---|---|
| committer | Cody Robibero <cody@robibe.ro> | 2026-11-20 07:23:42 -0500 |
| commit | 511f1ef882d594df64810d2c36b59ad381fd6e17 (patch) | |
| tree | 2a4dfabd381bbd23a1e1d65f9f9317c7deb659fb /tests/Jellyfin.Server.Implementations.Tests/Library | |
| parent | 00d8050bf661f6f9050a8de6e55585a8fe6d8beb (diff) | |
Backport pull request #18048 from jellyfin/release-12.z
Follow the Schedules Direct API contract when refreshing the guide
Original-merge: 85fa90cb758dabfb434fbd00c1128091007cf6a4
Merged-by: Bond-009 <bond.009@outlook.com>
Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'tests/Jellyfin.Server.Implementations.Tests/Library')
| -rw-r--r-- | tests/Jellyfin.Server.Implementations.Tests/Library/LibraryManagerConvertImageTests.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/LibraryManagerConvertImageTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/LibraryManagerConvertImageTests.cs new file mode 100644 index 0000000000..d374847e54 --- /dev/null +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/LibraryManagerConvertImageTests.cs @@ -0,0 +1,50 @@ +using System; +using System.Net; +using System.Threading; +using System.Threading.Tasks; +using AutoFixture; +using AutoFixture.AutoMoq; +using Emby.Naming.Common; +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Entities; +using Moq; +using Xunit; +using ServerLibraryManager = Emby.Server.Implementations.Library.LibraryManager; + +namespace Jellyfin.Server.Implementations.Tests.Library; + +public class LibraryManagerConvertImageTests +{ + [Theory] + [InlineData(HttpStatusCode.NotFound)] + [InlineData(HttpStatusCode.Forbidden)] + public async Task ConvertImageToLocal_RejectedDownload_KeepsTheResponseAsInnerException(HttpStatusCode status) + { + // The Live TV guide reads the provider's error body off the inner exception to stop + // requesting images from an account that is refusing them. + const string Body = "{\"response\":\"MAX_IMAGE_DOWNLOADS\",\"code\":5002}"; + var rejection = new HttpResponseBodyException("test", status, Body); + + var fixture = new Fixture().Customize(new AutoMoqCustomization()); + fixture.Register(() => new NamingOptions()); + var configuration = fixture.Freeze<Mock<IServerConfigurationManager>>(); + configuration.Setup(c => c.Configuration).Returns(new ServerConfiguration()); + configuration.Setup(c => c.ApplicationPaths.ProgramDataPath).Returns("/data"); + var providerManager = fixture.Freeze<Mock<IProviderManager>>(); + providerManager.Setup(p => p.SaveImage(It.IsAny<BaseItem>(), It.IsAny<string>(), It.IsAny<ImageType>(), It.IsAny<int?>(), It.IsAny<CancellationToken>())) + .ThrowsAsync(rejection); + var manager = fixture.Create<ServerLibraryManager>(); + + var item = new Movie { Id = Guid.NewGuid(), Name = "Test" }; + var image = new ItemImageInfo { Path = "https://example.com/image.jpg", Type = ImageType.Primary }; + + var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => manager.ConvertImageToLocal(item, image, 0, removeOnFailure: false)); + + Assert.Same(rejection, ex.InnerException); + } +} |
