1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-24 22:36:19 -04:00

Fixed: Removing completed download from SABnzbd

Closes #4445
This commit is contained in:
Mark McDowall
2021-04-19 22:00:33 -07:00
parent 6079f1ef11
commit c669be317f
26 changed files with 98 additions and 104 deletions
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@@ -25,6 +26,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
protected string _blackholeFolder;
protected string _filePath;
protected string _magnetFilePath;
protected DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
@@ -33,6 +35,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
_blackholeFolder = @"c:\blackhole\torrent".AsOsAgnostic();
_filePath = (@"c:\blackhole\torrent\" + _title + ".torrent").AsOsAgnostic();
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
Mocker.SetConstant<IScanWatchFolder>(Mocker.Resolve<ScanWatchFolder>());
Subject.Definition = new DownloadClientDefinition();
@@ -246,7 +252,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Once());
@@ -261,7 +267,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
.Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Once());
@@ -270,7 +276,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void RemoveItem_should_ignore_if_unknown_item()
{
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
@@ -284,7 +290,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
{
GivenCompletedItem();
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", false));
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem(_downloadClientItem, false));
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@@ -23,6 +24,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
protected string _completedDownloadFolder;
protected string _blackholeFolder;
protected string _filePath;
protected DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
@@ -31,6 +33,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
_blackholeFolder = @"c:\blackhole\nzb".AsOsAgnostic();
_filePath = (@"c:\blackhole\nzb\" + _title + ".nzb").AsOsAgnostic();
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
Mocker.SetConstant<IScanWatchFolder>(Mocker.Resolve<ScanWatchFolder>());
Subject.Definition = new DownloadClientDefinition();
@@ -146,7 +152,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Once());
@@ -161,7 +167,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
.Setup(c => c.FolderExists(It.IsAny<string>()))
.Returns(true);
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFolder(It.IsAny<string>(), true), Times.Once());
@@ -170,7 +176,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
[Test]
public void RemoveItem_should_ignore_if_unknown_item()
{
Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
@@ -184,7 +190,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
{
GivenCompletedItem();
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem("_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0", false));
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem(_downloadClientItem, false));
Mocker.GetMock<IDiskProvider>()
.Verify(c => c.DeleteFile(It.IsAny<string>()), Times.Never());
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@@ -20,6 +21,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
private NzbgetHistoryItem _failed;
private NzbgetHistoryItem _completed;
private Dictionary<string, string> _configItems;
private DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
@@ -74,6 +76,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
MarkStatus = "NONE"
};
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
Mocker.GetMock<INzbgetProxy>()
.Setup(s => s.GetGlobalStatus(It.IsAny<NzbgetSettings>()))
.Returns(new NzbgetGlobalStatus
@@ -156,7 +162,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.NzbgetTests
.Setup(v => v.FolderExists(It.IsAny<string>()))
.Returns(true);
Subject.RemoveItem("id", true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(It.IsAny<string>(), true), Times.Once());
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Http;
@@ -21,6 +22,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
private string _strmFolder;
private string _nzbPath;
private RemoteEpisode _remoteEpisode;
private DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
@@ -38,6 +40,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
_remoteEpisode.ParsedEpisodeInfo = new ParsedEpisodeInfo();
_remoteEpisode.ParsedEpisodeInfo.FullSeason = false;
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = "_Droned.S01E01.Pilot.1080p.WEB-DL-DRONE_0")
.Build();
Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = new PneumaticSettings
{
@@ -79,7 +85,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
[Test]
public void should_throw_item_is_removed()
{
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem("", true));
Assert.Throws<NotSupportedException>(() => Subject.RemoveItem(_downloadClientItem, true));
}
[Test]
@@ -24,6 +24,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
private SabnzbdHistory _completed;
private SabnzbdConfig _config;
private SabnzbdFullStatus _fullStatus;
private DownloadClientItem _downloadClientItem;
[SetUp]
public void Setup()
@@ -101,6 +102,10 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
}
};
_downloadClientItem = Builder<DownloadClientItem>
.CreateNew().With(d => d.DownloadId = _completed.Items.First().Id)
.Build();
Mocker.GetMock<ISabnzbdProxy>()
.Setup(v => v.GetVersion(It.IsAny<SabnzbdSettings>()))
.Returns("1.2.3");
@@ -591,7 +596,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
GivenQueue(null);
GivenHistory(_completed);
Subject.RemoveItem(_completed.Items.First().Id, true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(path, true), Times.Once);
@@ -618,7 +623,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
GivenQueue(null);
GivenHistory(_completed);
Subject.RemoveItem(_completed.Items.First().Id, true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(path, true), Times.Never);
@@ -645,7 +650,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
GivenQueue(null);
GivenHistory(_completed);
Subject.RemoveItem(_completed.Items.First().Id, true);
Subject.RemoveItem(_downloadClientItem, true);
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFolder(path, true), Times.Never);
@@ -672,7 +677,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.SabnzbdTests
GivenQueue(null);
GivenHistory(_completed);
Subject.RemoveItem(_completed.Items.First().Id, false);
Subject.RemoveItem(_downloadClientItem, false);
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.FolderExists(path), Times.Never);