mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-21 23:33:00 +00:00
parent
40f4ef27b2
commit
f9606518ee
4 changed files with 103 additions and 8 deletions
73
src/NzbDrone.Integration.Test/ApiTests/QueueFixture.cs
Normal file
73
src/NzbDrone.Integration.Test/ApiTests/QueueFixture.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Integration.Test.Client;
|
||||
using Sonarr.Api.V3.Queue;
|
||||
using Sonarr.Http;
|
||||
|
||||
namespace NzbDrone.Integration.Test.ApiTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class QueueFixture : IntegrationTest
|
||||
{
|
||||
private PagingResource<QueueResource> GetFirstPage()
|
||||
{
|
||||
var request = Queue.BuildRequest();
|
||||
request.AddParameter("includeUnknownSeriesItems", true);
|
||||
|
||||
return Queue.Get<PagingResource<QueueResource>>(request);
|
||||
}
|
||||
|
||||
private void RefreshQueue()
|
||||
{
|
||||
var command = Commands.Post(new SimpleCommandResource { Name = "RefreshMonitoredDownloads" });
|
||||
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
var updatedCommand = Commands.Get(command.Id);
|
||||
|
||||
if (updatedCommand.Status == CommandStatus.Completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Order(0)]
|
||||
public void ensure_queue_is_empty_when_download_client_is_configured()
|
||||
{
|
||||
EnsureNoDownloadClient();
|
||||
EnsureDownloadClient();
|
||||
|
||||
var queue = GetFirstPage();
|
||||
|
||||
queue.TotalRecords.Should().Be(0);
|
||||
queue.Records.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Order(1)]
|
||||
public void ensure_queue_is_not_empty()
|
||||
{
|
||||
EnsureNoDownloadClient();
|
||||
|
||||
var client = EnsureDownloadClient();
|
||||
var directory = client.Fields.First(v => v.Name == "watchFolder").Value as string;
|
||||
|
||||
File.WriteAllText(Path.Combine(directory, "Series.Title.S01E01.mkv"), "Test Download");
|
||||
RefreshQueue();
|
||||
|
||||
var queue = GetFirstPage();
|
||||
|
||||
queue.TotalRecords.Should().Be(1);
|
||||
queue.Records.Should().NotBeEmpty();
|
||||
}
|
||||
}
|
||||
}
|
13
src/NzbDrone.Integration.Test/Client/QueueClient.cs
Normal file
13
src/NzbDrone.Integration.Test/Client/QueueClient.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using RestSharp;
|
||||
using Sonarr.Api.V3.Queue;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
{
|
||||
public class QueueClient : ClientBase<QueueResource>
|
||||
{
|
||||
public QueueClient(IRestClient restClient, string apiKey)
|
||||
: base(restClient, apiKey)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,6 +57,7 @@ namespace NzbDrone.Integration.Test
|
|||
public ClientBase<TagResource> Tags;
|
||||
public ClientBase<EpisodeResource> WantedMissing;
|
||||
public ClientBase<EpisodeResource> WantedCutoffUnmet;
|
||||
public QueueClient Queue;
|
||||
|
||||
private List<SignalRMessage> _signalRReceived;
|
||||
|
||||
|
@ -121,6 +122,7 @@ namespace NzbDrone.Integration.Test
|
|||
Tags = new ClientBase<TagResource>(RestClient, ApiKey);
|
||||
WantedMissing = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/missing");
|
||||
WantedCutoffUnmet = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/cutoff");
|
||||
Queue = new QueueClient(RestClient, ApiKey);
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
|
|
|
@ -26,8 +26,11 @@ namespace Sonarr.Api.V3.Queue
|
|||
public int CustomFormatScore { get; set; }
|
||||
public decimal Size { get; set; }
|
||||
public string Title { get; set; }
|
||||
public decimal SizeLeft { get; set; }
|
||||
public TimeSpan? TimeLeft { get; set; }
|
||||
|
||||
// Collides with existing properties due to case-insensitive deserialization
|
||||
// public decimal SizeLeft { get; set; }
|
||||
// public TimeSpan? TimeLeft { get; set; }
|
||||
|
||||
public DateTime? EstimatedCompletionTime { get; set; }
|
||||
public DateTime? Added { get; set; }
|
||||
public QueueStatus Status { get; set; }
|
||||
|
@ -43,9 +46,10 @@ namespace Sonarr.Api.V3.Queue
|
|||
public string OutputPath { get; set; }
|
||||
public bool EpisodeHasFile { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
[Obsolete("Will be replaced by SizeLeft")]
|
||||
public decimal Sizeleft { get; set; }
|
||||
[Obsolete]
|
||||
|
||||
[Obsolete("Will be replaced by TimeLeft")]
|
||||
public TimeSpan? Timeleft { get; set; }
|
||||
}
|
||||
|
||||
|
@ -75,8 +79,11 @@ namespace Sonarr.Api.V3.Queue
|
|||
CustomFormatScore = customFormatScore,
|
||||
Size = model.Size,
|
||||
Title = model.Title,
|
||||
SizeLeft = model.SizeLeft,
|
||||
TimeLeft = model.TimeLeft,
|
||||
|
||||
// Collides with existing properties due to case-insensitive deserialization
|
||||
// SizeLeft = model.SizeLeft,
|
||||
// TimeLeft = model.TimeLeft,
|
||||
|
||||
EstimatedCompletionTime = model.EstimatedCompletionTime,
|
||||
Added = model.Added,
|
||||
Status = model.Status,
|
||||
|
@ -92,10 +99,10 @@ namespace Sonarr.Api.V3.Queue
|
|||
OutputPath = model.OutputPath,
|
||||
EpisodeHasFile = model.Episode?.HasFile ?? false,
|
||||
|
||||
#pragma warning disable CS0612
|
||||
#pragma warning disable CS0618
|
||||
Sizeleft = model.SizeLeft,
|
||||
Timeleft = model.TimeLeft,
|
||||
#pragma warning restore CS0612
|
||||
#pragma warning restore CS0618
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue