Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
FRAMEWORK: net10.0
RAW_BRANCH_NAME: ${{ inputs.branch || github.head_ref || github.ref_name }}
RADARR_MAJOR_VERSION: 6
VERSION: ${{ inputs.version || '6.0.4' }}
VERSION: ${{ inputs.version || '6.4.2' }}

jobs:
prepare:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
FRAMEWORK: net10.0
RAW_BRANCH_NAME: main
RADARR_MAJOR_VERSION: 6
VERSION: '6.0.5'
VERSION: '6.4.2'

jobs:
prepare:
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Automation.Test/Radarr.Automation.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Selenium.Support" Version="4.46.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="150.0.7871.12400" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="151.0.7922.7100" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Test.Common\Radarr.Test.Common.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Common/Radarr.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="NLog.Layouts.ClefJsonLayout" Version="1.0.5" />
<PackageReference Include="Npgsql" Version="10.0.3" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="SourceGear.sqlite3" Version="3.53.3" />
<PackageReference Include="SourceGear.sqlite3" Version="3.53.4" />
<PackageReference Include="System.Data.SQLite" Version="2.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.6.2" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.10" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.RQBit;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Test.Common;

namespace NzbDrone.Core.Test.Download.DownloadClientTests.RQBitTests
{
[TestFixture]
public class RQBitFixture : DownloadClientFixtureBase<RQBit>
{
protected RQBitTorrent _queued;
protected RQBitTorrent _downloading;
protected RQBitTorrent _failed;
protected RQBitTorrent _completed;

[SetUp]
public void Setup()
{
Subject.Definition = new DownloadClientDefinition();
Subject.Definition.Settings = new RQbitSettings
{
Host = "127.0.0.1",
Port = 3030,
UseSsl = false
};

_queued = new RQBitTorrent
{
Hash = "HASH",
IsFinished = false,
IsActive = false,
Name = _title,
TotalSize = 1000,
RemainingSize = 1000,
Path = "somepath"
};

_downloading = new RQBitTorrent
{
Hash = "HASH",
IsFinished = false,
IsActive = true,
Name = _title,
TotalSize = 1000,
RemainingSize = 100,
Path = "somepath"
};

_failed = new RQBitTorrent
{
Hash = "HASH",
IsFinished = false,
IsActive = false,
Name = _title,
TotalSize = 1000,
RemainingSize = 1000,
Path = "somepath"
};

_completed = new RQBitTorrent
{
Hash = "HASH",
IsFinished = true,
IsActive = false,
Name = _title,
TotalSize = 1000,
RemainingSize = 0,
Path = "somepath"
};

Mocker.GetMock<ITorrentFileInfoReader>()
.Setup(s => s.GetHashFromTorrentFile(It.IsAny<byte[]>()))
.Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");
}

protected void GivenSuccessfulDownload()
{
Mocker.GetMock<IRQbitProxy>()
.Setup(s => s.AddTorrentFromUrl(It.IsAny<string>(), It.IsAny<RQbitSettings>()))
.Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");
Mocker.GetMock<IRQbitProxy>()
.Setup(s => s.AddTorrentFromFile(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<RQbitSettings>()))
.Returns("CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951");
}

protected virtual void GivenTorrents(List<RQBitTorrent> torrents)
{
if (torrents == null)
{
torrents = new List<RQBitTorrent>();
}

Mocker.GetMock<IRQbitProxy>()
.Setup(s => s.GetTorrents(It.IsAny<RQbitSettings>()))
.Returns(torrents);
}

protected void PrepareClientToReturnQueuedItem()
{
GivenTorrents(new List<RQBitTorrent>
{
_queued
});
}

protected void PrepareClientToReturnDownloadingItem()
{
GivenTorrents(new List<RQBitTorrent>
{
_downloading
});
}

protected void PrepareClientToReturnFailedItem()
{
GivenTorrents(new List<RQBitTorrent>
{
_failed
});
}

protected void PrepareClientToReturnCompletedItem()
{
GivenTorrents(new List<RQBitTorrent>
{
_completed
});
}

[Test]
public void queued_item_should_have_required_properties()
{
PrepareClientToReturnQueuedItem();
var item = Subject.GetItems().Single();
VerifyPaused(item);
}

[Test]
public void downloading_item_should_have_required_properties()
{
PrepareClientToReturnDownloadingItem();
var item = Subject.GetItems().Single();
VerifyDownloading(item);
}

[Test]
public void failed_item_should_have_required_properties()
{
PrepareClientToReturnFailedItem();
var item = Subject.GetItems().Single();
VerifyPaused(item);
}

[Test]
public void completed_download_should_have_required_properties()
{
PrepareClientToReturnCompletedItem();
var item = Subject.GetItems().Single();
VerifyCompleted(item);
}

[Test]
public async Task Download_should_return_unique_id()
{
GivenSuccessfulDownload();

var remoteEpisode = CreateRemoteMovie();

var id = await Subject.Download(remoteEpisode, CreateIndexer());

id.Should().NotBeNullOrEmpty();
}

[TestCase("magnet:?xt=urn:btih:ZPBPA2P6ROZPKRHK44D5OW6NHXU5Z6KR&tr=udp", "CBC2F069FE8BB2F544EAE707D75BCD3DE9DCF951")]
public async Task Download_should_get_hash_from_magnet_url(string magnetUrl, string expectedHash)
{
GivenSuccessfulDownload();

var remoteEpisode = CreateRemoteMovie();
remoteEpisode.Release.DownloadUrl = magnetUrl;

var id = await Subject.Download(remoteEpisode, CreateIndexer());

id.Should().Be(expectedHash);
}

[Test]
public void should_return_status_with_outputdirs()
{
var result = Subject.GetStatus();

result.IsLocalhost.Should().BeTrue();
}

[Test]
public void GetItems_should_ignore_torrents_with_empty_path()
{
var torrents = new List<RQBitTorrent>
{
new RQBitTorrent { Name = "Test1", Hash = "Hash1", Path = "" },
new RQBitTorrent { Name = "Test2", Hash = "Hash2", Path = "/valid/path" }
};

GivenTorrents(torrents);

var items = Subject.GetItems();

items.Should().HaveCount(1);
items.First().Title.Should().Be("Test2");
ExceptionVerification.ExpectedWarns(1);
}

[Test]
public void GetItems_should_ignore_torrents_with_relative_path()
{
var torrents = new List<RQBitTorrent>
{
new RQBitTorrent { Name = "Test1", Hash = "Hash1", Path = "./relative/path" },
new RQBitTorrent { Name = "Test2", Hash = "Hash2", Path = "/absolute/path" }
};

GivenTorrents(torrents);

var items = Subject.GetItems();

items.Should().HaveCount(1);
items.First().Title.Should().Be("Test2");
ExceptionVerification.ExpectedWarns(1);
}
}
}
Loading
Loading