1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Sabnzbd 1.1.0 rc4 queue api changed time format.

This commit is contained in:
Taloth Saldono 2016-09-03 11:41:34 +02:00
parent a6a7732cd5
commit 97d0ddb6e9
2 changed files with 17 additions and 13 deletions

View File

@ -12,32 +12,35 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests.JsonConve
[TestFixture]
public class SabnzbdQueueTimeConverterFixture
{
private const string QUERY =
"{0} status : 'Downloading', mb : 1000, filename : 'Droned.S01E01.Pilot.1080p.WEB-DL-DRONE', priority : 0, cat : 'tv', mbleft : 10, percentage : 90, nzo_id : 'sabnzbd_nzb12345', timeleft : '{1}' {2}";
private const string QUERY = "{{ timeleft : '{0}' }}";
[TestCase("0:0:1")]
[TestCase("0:0:0:1")]
public void valid_time_formats_should_be_parsed_correctly(string time)
[TestCase("0:0:0", 0)]
[TestCase("0:1:59", 119)]
[TestCase("0:59:59", 3599)]
[TestCase("1:0:0", 3600)]
[TestCase("1:0:0:1", 24 * 3600 + 1)]
[TestCase("40:12:14", 40 * 3600 + 12 * 60 + 14)]
[TestCase("1:16:12:14", 40 * 3600 + 12 * 60 + 14)]
public void valid_time_formats_should_be_parsed_correctly(string time, int expectedSeconds)
{
var thing = string.Format(QUERY, "{", time, "}");
var thing = string.Format(QUERY, time);
var item = JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing);
item.Timeleft.Should().Be(new TimeSpan(0, 0, 1));
item.Timeleft.Should().Be(TimeSpan.FromSeconds(expectedSeconds));
}
[TestCase("0:1")]
[TestCase("1")]
[TestCase("0:1")]
[TestCase("0:0:0:0:1")]
public void invalid_time_formats_should_throw_an_exception(string time)
{
var thing = string.Format(QUERY, "{", time, "}");
var thing = string.Format(QUERY, time);
Assert.That(() => JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing), Throws.TypeOf<ArgumentException>());
}
[TestCase("40:12:14")]
[TestCase("1:16:12:14")]
public void valid_time_formats_of_equal_value_should_be_parsed_the_same(string time)
[Test]
public void should_support_pre_1_1_0rc4_format()
{
var thing = string.Format(QUERY, "{", time, "}");
var thing = string.Format(QUERY, "40:12:14");
var item = JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing);
item.Timeleft.Should().Be(new TimeSpan(40, 12, 14));
}

View File

@ -171,6 +171,7 @@
<Compile Include="Download\DownloadClientTests\PneumaticProviderFixture.cs" />
<Compile Include="Download\DownloadClientTests\RTorrentTests\RTorrentFixture.cs" />
<Compile Include="Download\DownloadClientTests\QBittorrentTests\QBittorrentFixture.cs" />
<Compile Include="Download\DownloadClientTests\SabnzbdTests\JsonConvertersTests\SabnzbdQueueTimeConverterFixture.cs" />
<Compile Include="Download\DownloadClientTests\SabnzbdTests\SabnzbdFixture.cs" />
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixture.cs" />
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixtureBase.cs" />