mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-24 22:36:19 -04:00
Fixed: DownloadStation proxy failing if non-bt/nzb downloads exist.
This commit is contained in:
+35
-13
@@ -304,7 +304,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
_settings.TvDirectory = _tvDirectory;
|
||||
}
|
||||
|
||||
protected virtual void GivenTorrents(List<DownloadStationTask> torrents)
|
||||
protected virtual void GivenTasks(List<DownloadStationTask> torrents)
|
||||
{
|
||||
if (torrents == null)
|
||||
{
|
||||
@@ -312,13 +312,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
}
|
||||
|
||||
Mocker.GetMock<IDownloadStationProxy>()
|
||||
.Setup(s => s.GetTasks(DownloadStationTaskType.BT, It.IsAny<DownloadStationSettings>()))
|
||||
.Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
|
||||
.Returns(torrents);
|
||||
}
|
||||
|
||||
protected void PrepareClientToReturnQueuedItem()
|
||||
{
|
||||
GivenTorrents(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_queued
|
||||
});
|
||||
@@ -353,7 +353,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
var tasks = new List<DownloadStationTask>() { _queued, _completed, _failed, _downloading, _seeding };
|
||||
|
||||
Mocker.GetMock<IDownloadStationProxy>()
|
||||
.Setup(d => d.GetTasks(DownloadStationTaskType.BT, _settings))
|
||||
.Setup(d => d.GetTasks(_settings))
|
||||
.Returns(tasks);
|
||||
|
||||
return tasks.Count;
|
||||
@@ -409,6 +409,28 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
.Verify(v => v.AddTaskFromUrl(It.IsAny<string>(), null, It.IsAny<DownloadStationSettings>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItems_should_return_empty_list_if_no_tasks_available()
|
||||
{
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenTasks(new List<DownloadStationTask>());
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItems_should_return_ignore_tasks_of_unknown_type()
|
||||
{
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenTasks(new List<DownloadStationTask> { _completed });
|
||||
|
||||
_completed.Type = "ipfs";
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItems_should_ignore_downloads_in_wrong_folder()
|
||||
{
|
||||
@@ -416,7 +438,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenTorrents(new List<DownloadStationTask> { _completed });
|
||||
GivenTasks(new List<DownloadStationTask> { _completed });
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
@@ -470,7 +492,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _singleFile });
|
||||
GivenTasks(new List<DownloadStationTask>() { _singleFile });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -484,7 +506,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _multipleFiles });
|
||||
GivenTasks(new List<DownloadStationTask>() { _multipleFiles });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -498,7 +520,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _singleFileCompleted });
|
||||
GivenTasks(new List<DownloadStationTask>() { _singleFileCompleted });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -512,7 +534,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _multipleFilesCompleted });
|
||||
GivenTasks(new List<DownloadStationTask>() { _multipleFilesCompleted });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -526,7 +548,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_queued, _downloading
|
||||
});
|
||||
@@ -543,7 +565,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_completed, _failed, _seeding
|
||||
});
|
||||
@@ -565,7 +587,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
_queued.Status = apiStatus;
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _queued });
|
||||
GivenTasks(new List<DownloadStationTask>() { _queued });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -589,7 +611,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
_queued.Status = apiStatus;
|
||||
|
||||
GivenTorrents(new List<DownloadStationTask>() { _queued });
|
||||
GivenTasks(new List<DownloadStationTask>() { _queued });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
items.Should().HaveCount(1);
|
||||
|
||||
+23
-13
@@ -206,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
_settings.TvDirectory = _tvDirectory;
|
||||
}
|
||||
|
||||
protected virtual void GivenNZBs(List<DownloadStationTask> nzbs)
|
||||
protected virtual void GivenTasks(List<DownloadStationTask> nzbs)
|
||||
{
|
||||
if (nzbs == null)
|
||||
{
|
||||
@@ -214,13 +214,13 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
}
|
||||
|
||||
Mocker.GetMock<IDownloadStationProxy>()
|
||||
.Setup(s => s.GetTasks(DownloadStationTaskType.NZB, It.IsAny<DownloadStationSettings>()))
|
||||
.Setup(s => s.GetTasks(It.IsAny<DownloadStationSettings>()))
|
||||
.Returns(nzbs);
|
||||
}
|
||||
|
||||
protected void PrepareClientToReturnQueuedItem()
|
||||
{
|
||||
GivenNZBs(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_queued
|
||||
});
|
||||
@@ -243,7 +243,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
var tasks = new List<DownloadStationTask>() { _queued, _completed, _failed, _downloading, _seeding };
|
||||
|
||||
Mocker.GetMock<IDownloadStationProxy>()
|
||||
.Setup(d => d.GetTasks(DownloadStationTaskType.NZB, _settings))
|
||||
.Setup(d => d.GetTasks(_settings))
|
||||
.Returns(tasks);
|
||||
}
|
||||
|
||||
@@ -300,11 +300,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
[Test]
|
||||
public void GetItems_should_return_empty_list_if_no_tasks_available()
|
||||
{
|
||||
_settings.TvDirectory = @"/shared/folder/sub";
|
||||
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenNZBs(new List<DownloadStationTask>());
|
||||
GivenTasks(new List<DownloadStationTask>());
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItems_should_return_ignore_tasks_of_unknown_type()
|
||||
{
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenTasks(new List<DownloadStationTask> { _completed });
|
||||
|
||||
_completed.Type = "ipfs";
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
@@ -316,7 +326,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
GivenNZBs(new List<DownloadStationTask> { _completed });
|
||||
GivenTasks(new List<DownloadStationTask> { _completed });
|
||||
|
||||
Subject.GetItems().Should().BeEmpty();
|
||||
}
|
||||
@@ -350,7 +360,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Download_should_throw_and_not_add_tasks_if_cannot_get_serial_number()
|
||||
public void Download_should_throw_and_not_add_task_if_cannot_get_serial_number()
|
||||
{
|
||||
var remoteEpisode = CreateRemoteEpisode();
|
||||
|
||||
@@ -370,7 +380,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenNZBs(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_queued, _downloading
|
||||
});
|
||||
@@ -387,7 +397,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
GivenSerialNumber();
|
||||
GivenSharedFolder();
|
||||
|
||||
GivenNZBs(new List<DownloadStationTask>
|
||||
GivenTasks(new List<DownloadStationTask>
|
||||
{
|
||||
_completed, _failed, _seeding
|
||||
});
|
||||
@@ -408,7 +418,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
_queued.Status = apiStatus;
|
||||
|
||||
GivenNZBs(new List<DownloadStationTask>() { _queued });
|
||||
GivenTasks(new List<DownloadStationTask>() { _queued });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
|
||||
@@ -431,7 +441,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
|
||||
_queued.Status = apiStatus;
|
||||
|
||||
GivenNZBs(new List<DownloadStationTask>() { _queued });
|
||||
GivenTasks(new List<DownloadStationTask>() { _queued });
|
||||
|
||||
var items = Subject.GetItems();
|
||||
items.Should().HaveCount(1);
|
||||
|
||||
Reference in New Issue
Block a user