Fixed: Sabnzbd 1.1.0 rc4 queue api changed time format.
This commit is contained in:
parent
a6a7732cd5
commit
97d0ddb6e9
|
@ -12,32 +12,35 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests.JsonConve
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class SabnzbdQueueTimeConverterFixture
|
public class SabnzbdQueueTimeConverterFixture
|
||||||
{
|
{
|
||||||
private const string QUERY =
|
private const string QUERY = "{{ timeleft : '{0}' }}";
|
||||||
"{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}";
|
|
||||||
|
|
||||||
[TestCase("0:0:1")]
|
[TestCase("0:0:0", 0)]
|
||||||
[TestCase("0:0:0:1")]
|
[TestCase("0:1:59", 119)]
|
||||||
public void valid_time_formats_should_be_parsed_correctly(string time)
|
[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);
|
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("1")]
|
||||||
|
[TestCase("0:1")]
|
||||||
[TestCase("0:0:0:0:1")]
|
[TestCase("0:0:0:0:1")]
|
||||||
public void invalid_time_formats_should_throw_an_exception(string time)
|
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>());
|
Assert.That(() => JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing), Throws.TypeOf<ArgumentException>());
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("40:12:14")]
|
[Test]
|
||||||
[TestCase("1:16:12:14")]
|
public void should_support_pre_1_1_0rc4_format()
|
||||||
public void valid_time_formats_of_equal_value_should_be_parsed_the_same(string time)
|
|
||||||
{
|
{
|
||||||
var thing = string.Format(QUERY, "{", time, "}");
|
var thing = string.Format(QUERY, "40:12:14");
|
||||||
var item = JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing);
|
var item = JsonConvert.DeserializeObject<SabnzbdQueueItem>(thing);
|
||||||
item.Timeleft.Should().Be(new TimeSpan(40, 12, 14));
|
item.Timeleft.Should().Be(new TimeSpan(40, 12, 14));
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@
|
||||||
<Compile Include="Download\DownloadClientTests\PneumaticProviderFixture.cs" />
|
<Compile Include="Download\DownloadClientTests\PneumaticProviderFixture.cs" />
|
||||||
<Compile Include="Download\DownloadClientTests\RTorrentTests\RTorrentFixture.cs" />
|
<Compile Include="Download\DownloadClientTests\RTorrentTests\RTorrentFixture.cs" />
|
||||||
<Compile Include="Download\DownloadClientTests\QBittorrentTests\QBittorrentFixture.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\SabnzbdTests\SabnzbdFixture.cs" />
|
||||||
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixture.cs" />
|
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixture.cs" />
|
||||||
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixtureBase.cs" />
|
<Compile Include="Download\DownloadClientTests\TransmissionTests\TransmissionFixtureBase.cs" />
|
||||||
|
|
Loading…
Reference in New Issue