mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Fix Unit Tests Build (#13)
* Fix Unit Tests Build * Updated Manage Artists view Fix Unit Tests Build * Small UI fixes Small UI fixes
This commit is contained in:
parent
8b98cd8825
commit
4cfd39f7fe
37 changed files with 937 additions and 862 deletions
|
@ -1,36 +1,38 @@
|
||||||
using NzbDrone.Api.Episodes;
|
using NzbDrone.Api.Episodes;
|
||||||
|
using NzbDrone.Api.Albums;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Wanted
|
namespace NzbDrone.Api.Wanted
|
||||||
{
|
{
|
||||||
public class MissingModule : EpisodeModuleWithSignalR
|
public class MissingModule : AlbumModuleWithSignalR
|
||||||
{
|
{
|
||||||
public MissingModule(IEpisodeService episodeService,
|
public MissingModule(IAlbumService albumService,
|
||||||
ISeriesService seriesService,
|
IArtistService artistService,
|
||||||
IQualityUpgradableSpecification qualityUpgradableSpecification,
|
IQualityUpgradableSpecification qualityUpgradableSpecification,
|
||||||
IBroadcastSignalRMessage signalRBroadcaster)
|
IBroadcastSignalRMessage signalRBroadcaster)
|
||||||
: base(episodeService, seriesService, qualityUpgradableSpecification, signalRBroadcaster, "wanted/missing")
|
: base(albumService, artistService, qualityUpgradableSpecification, signalRBroadcaster, "wanted/missing")
|
||||||
{
|
{
|
||||||
GetResourcePaged = GetMissingEpisodes;
|
GetResourcePaged = GetMissingAlbums;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagingResource<EpisodeResource> GetMissingEpisodes(PagingResource<EpisodeResource> pagingResource)
|
private PagingResource<AlbumResource> GetMissingAlbums(PagingResource<AlbumResource> pagingResource)
|
||||||
{
|
{
|
||||||
var pagingSpec = pagingResource.MapToPagingSpec<EpisodeResource, Episode>("airDateUtc", SortDirection.Descending);
|
var pagingSpec = pagingResource.MapToPagingSpec<AlbumResource, Album>("releaseDate", SortDirection.Descending);
|
||||||
|
|
||||||
if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
|
if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
|
||||||
{
|
{
|
||||||
pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
|
pagingSpec.FilterExpression = v => v.Monitored == false || v.Artist.Monitored == false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
|
pagingSpec.FilterExpression = v => v.Monitored == true && v.Artist.Monitored == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec, v => MapToResource(v, true, false));
|
var resource = ApplyToPage(_albumService.AlbumsWithoutFiles, pagingSpec, v => MapToResource(v, true));
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,13 @@ using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
using NzbDrone.Core.History;
|
using NzbDrone.Core.History;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||||
|
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.Download
|
namespace NzbDrone.Core.Test.Download
|
||||||
|
@ -84,7 +86,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
new ImportResult(new ImportDecision(new LocalTrack() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,11 +186,11 @@ namespace NzbDrone.Core.Test.Download
|
||||||
{
|
{
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||||
|
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"}))
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E02.mkv"}))
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Process(_trackedDownload);
|
Subject.Process(_trackedDownload);
|
||||||
|
@ -205,11 +207,11 @@ namespace NzbDrone.Core.Test.Download
|
||||||
{
|
{
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
||||||
|
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Process(_trackedDownload);
|
Subject.Process(_trackedDownload);
|
||||||
|
@ -229,11 +231,11 @@ namespace NzbDrone.Core.Test.Download
|
||||||
{
|
{
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
||||||
|
|
||||||
new ImportResult(
|
new ImportResult(
|
||||||
new ImportDecision(
|
new ImportDecision(
|
||||||
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
new LocalTrack {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
||||||
});
|
});
|
||||||
|
|
||||||
_trackedDownload.RemoteEpisode.Episodes.Clear();
|
_trackedDownload.RemoteEpisode.Episodes.Clear();
|
||||||
|
@ -250,8 +252,8 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,8 +276,8 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
new ImportResult(new ImportDecision(new LocalTrack{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Process(_trackedDownload);
|
Subject.Process(_trackedDownload);
|
||||||
|
@ -297,9 +299,9 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
new ImportResult(new ImportDecision(new LocalTrack{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
new ImportResult(new ImportDecision(new LocalTrack{Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,7 +319,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||||
});
|
});
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>()
|
Mocker.GetMock<ISeriesService>()
|
||||||
|
@ -338,7 +340,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||||
});
|
});
|
||||||
|
|
||||||
Mocker.GetMock<IHistoryService>()
|
Mocker.GetMock<IHistoryService>()
|
||||||
|
@ -373,7 +375,7 @@ namespace NzbDrone.Core.Test.Download
|
||||||
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
||||||
.Returns(new List<ImportResult>
|
.Returns(new List<ImportResult>
|
||||||
{
|
{
|
||||||
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
new ImportResult(new ImportDecision(new LocalTrack {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Process(_trackedDownload, true);
|
Subject.Process(_trackedDownload, true);
|
||||||
|
|
|
@ -10,6 +10,7 @@ using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
@ -17,19 +18,19 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ScanFixture : CoreTest<DiskScanService>
|
public class ScanFixture : CoreTest<DiskScanService>
|
||||||
{
|
{
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
private string _rootFolder;
|
private string _rootFolder;
|
||||||
private string _otherSeriesFolder;
|
private string _otherArtistFolder;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_rootFolder = @"C:\Test\TV".AsOsAgnostic();
|
_rootFolder = @"C:\Test\Music".AsOsAgnostic();
|
||||||
_otherSeriesFolder = @"C:\Test\TV\OtherSeries".AsOsAgnostic();
|
_otherArtistFolder = @"C:\Test\Music\OtherArtist".AsOsAgnostic();
|
||||||
var seriesFolder = @"C:\Test\TV\Series".AsOsAgnostic();
|
var artistFolder = @"C:\Test\Music\Artist".AsOsAgnostic();
|
||||||
|
|
||||||
_series = Builder<Series>.CreateNew()
|
_artist = Builder<Artist>.CreateNew()
|
||||||
.With(s => s.Path = seriesFolder)
|
.With(s => s.Path = artistFolder)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -61,7 +62,7 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
private void GivenSeriesFolder()
|
private void GivenSeriesFolder()
|
||||||
{
|
{
|
||||||
GivenRootFolder(_series.Path);
|
GivenRootFolder(_artist.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenFiles(IEnumerable<string> files)
|
private void GivenFiles(IEnumerable<string> files)
|
||||||
|
@ -74,15 +75,15 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_scan_if_root_folder_does_not_exist()
|
public void should_not_scan_if_root_folder_does_not_exist()
|
||||||
{
|
{
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.FolderExists(_series.Path), Times.Never());
|
.Verify(v => v.FolderExists(_artist.Path), Times.Never());
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||||
.Verify(v => v.Clean(It.IsAny<Series>(), It.IsAny<List<string>>()), Times.Never());
|
.Verify(v => v.Clean(It.IsAny<Artist>(), It.IsAny<List<string>>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -90,83 +91,83 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
{
|
{
|
||||||
GivenRootFolder();
|
GivenRootFolder();
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
ExceptionVerification.ExpectedWarns(1);
|
ExceptionVerification.ExpectedWarns(1);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.FolderExists(_series.Path), Times.Never());
|
.Verify(v => v.FolderExists(_artist.Path), Times.Never());
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||||
.Verify(v => v.Clean(It.IsAny<Series>(), It.IsAny<List<string>>()), Times.Never());
|
.Verify(v => v.Clean(It.IsAny<Artist>(), It.IsAny<List<string>>()), Times.Never());
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _series), Times.Never());
|
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _artist), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_create_if_series_folder_does_not_exist_but_create_folder_enabled()
|
public void should_create_if_series_folder_does_not_exist_but_create_folder_enabled()
|
||||||
{
|
{
|
||||||
GivenRootFolder(_otherSeriesFolder);
|
GivenRootFolder(_otherArtistFolder);
|
||||||
|
|
||||||
Mocker.GetMock<IConfigService>()
|
Mocker.GetMock<IConfigService>()
|
||||||
.Setup(s => s.CreateEmptySeriesFolders)
|
.Setup(s => s.CreateEmptySeriesFolders)
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.CreateFolder(_series.Path), Times.Once());
|
.Verify(v => v.CreateFolder(_artist.Path), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_create_if_series_folder_does_not_exist_and_create_folder_disabled()
|
public void should_not_create_if_series_folder_does_not_exist_and_create_folder_disabled()
|
||||||
{
|
{
|
||||||
GivenRootFolder(_otherSeriesFolder);
|
GivenRootFolder(_otherArtistFolder);
|
||||||
|
|
||||||
Mocker.GetMock<IConfigService>()
|
Mocker.GetMock<IConfigService>()
|
||||||
.Setup(s => s.CreateEmptySeriesFolders)
|
.Setup(s => s.CreateEmptySeriesFolders)
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.CreateFolder(_series.Path), Times.Never());
|
.Verify(v => v.CreateFolder(_artist.Path), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_clean_but_not_import_if_series_folder_does_not_exist()
|
public void should_clean_but_not_import_if_series_folder_does_not_exist()
|
||||||
{
|
{
|
||||||
GivenRootFolder(_otherSeriesFolder);
|
GivenRootFolder(_otherArtistFolder);
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.FolderExists(_series.Path), Times.Once());
|
.Verify(v => v.FolderExists(_artist.Path), Times.Once());
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||||
.Verify(v => v.Clean(It.IsAny<Series>(), It.IsAny<List<string>>()), Times.Once());
|
.Verify(v => v.Clean(It.IsAny<Artist>(), It.IsAny<List<string>>()), Times.Once());
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _series), Times.Never());
|
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _artist), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_clean_but_not_import_if_series_folder_does_not_exist_and_create_folder_enabled()
|
public void should_clean_but_not_import_if_series_folder_does_not_exist_and_create_folder_enabled()
|
||||||
{
|
{
|
||||||
GivenRootFolder(_otherSeriesFolder);
|
GivenRootFolder(_otherArtistFolder);
|
||||||
|
|
||||||
Mocker.GetMock<IConfigService>()
|
Mocker.GetMock<IConfigService>()
|
||||||
.Setup(s => s.CreateEmptySeriesFolders)
|
.Setup(s => s.CreateEmptySeriesFolders)
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileTableCleanupService>()
|
Mocker.GetMock<IMediaFileTableCleanupService>()
|
||||||
.Verify(v => v.Clean(It.IsAny<Series>(), It.IsAny<List<string>>()), Times.Once());
|
.Verify(v => v.Clean(It.IsAny<Artist>(), It.IsAny<List<string>>()), Times.Once());
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _series), Times.Never());
|
.Verify(v => v.GetImportDecisions(It.IsAny<List<string>>(), _artist), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -176,14 +177,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -193,20 +194,20 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "EXTRAS", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Extras", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Extras", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "EXTRAs", "file3.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "ExTrAs", "file4.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Verify(v => v.GetFiles(It.IsAny<string>(), It.IsAny<SearchOption>()), Times.Once());
|
.Verify(v => v.GetFiles(It.IsAny<string>(), It.IsAny<SearchOption>()), Times.Once());
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -216,38 +217,38 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".AppleDouble", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, ".appledouble", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".appledouble", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_scan_extras_series_and_subfolders()
|
public void should_scan_extras_series_and_subfolders()
|
||||||
{
|
{
|
||||||
_series.Path = @"C:\Test\TV\Extras".AsOsAgnostic();
|
_artist.Path = @"C:\Test\TV\Extras".AsOsAgnostic();
|
||||||
|
|
||||||
GivenSeriesFolder();
|
GivenSeriesFolder();
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "Extras", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Extras", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".AppleDouble", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", "s01e02.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 2", "s02e01.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 2", "s02e02.mkv").AsOsAgnostic(),
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 4), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 4), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -257,16 +258,16 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, ".hidden", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -276,17 +277,17 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", ".@__THUMB", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", ".hidden", "file2.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", ".AppleDouble", "s01e01.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -296,14 +297,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "@eaDir", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "@eaDir", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -313,33 +314,33 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, ".@__thumb", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_scan_dotHack_folder()
|
public void should_scan_dotHack_folder()
|
||||||
{
|
{
|
||||||
_series.Path = @"C:\Test\TV\.hack".AsOsAgnostic();
|
_artist.Path = @"C:\Test\TV\.hack".AsOsAgnostic();
|
||||||
|
|
||||||
GivenSeriesFolder();
|
GivenSeriesFolder();
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "Season 1", "file1.mkv").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "Season 1", "file1.mkv").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "Season 1", "s01e01.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 2), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -349,14 +350,14 @@ namespace NzbDrone.Core.Test.MediaFiles.DiskScanServiceTests
|
||||||
|
|
||||||
GivenFiles(new List<string>
|
GivenFiles(new List<string>
|
||||||
{
|
{
|
||||||
Path.Combine(_series.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(),
|
Path.Combine(_artist.Path, "._24 The Status Quo Combustion.mp4").AsOsAgnostic(),
|
||||||
Path.Combine(_series.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic()
|
Path.Combine(_artist.Path, "24 The Status Quo Combustion.mkv").AsOsAgnostic()
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.Scan(_series);
|
Subject.Scan(_artist);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _series), Times.Once());
|
.Verify(v => v.GetImportDecisions(It.Is<List<string>>(l => l.Count == 1), _artist), Times.Once());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -10,6 +10,7 @@ using NzbDrone.Core.Download.TrackedDownloads;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.Commands;
|
using NzbDrone.Core.MediaFiles.Commands;
|
||||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||||
|
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
|
@ -6,19 +6,21 @@ using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class DownloadedEpisodesImportServiceFixture : CoreTest<DownloadedEpisodesImportService>
|
public class DownloadedTracksImportServiceFixture : CoreTest<DownloadedEpisodesImportService>
|
||||||
{
|
{
|
||||||
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
private string _droneFactory = "c:\\drop\\".AsOsAgnostic();
|
||||||
private string[] _subFolders = new[] { "c:\\root\\foldername".AsOsAgnostic() };
|
private string[] _subFolders = new[] { "c:\\root\\foldername".AsOsAgnostic() };
|
||||||
|
@ -36,7 +38,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FolderExists(It.IsAny<string>()))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedTracks>()
|
||||||
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
.Setup(s => s.Import(It.IsAny<List<ImportDecision>>(), true, null, ImportMode.Auto))
|
||||||
.Returns(new List<ImportResult>());
|
.Returns(new List<ImportResult>());
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
Subject.ProcessRootFolder(new DirectoryInfo(_droneFactory));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()),
|
.Verify(c => c.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()),
|
||||||
Times.Never());
|
Times.Never());
|
||||||
|
|
||||||
VerifyNoImport();
|
VerifyNoImport();
|
||||||
|
@ -122,13 +124,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenValidSeries();
|
GivenValidSeries();
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
@ -148,13 +150,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenValidSeries();
|
GivenValidSeries();
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
@ -210,8 +212,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
result.Should().HaveCount(1);
|
result.Should().HaveCount(1);
|
||||||
result.First().ImportDecision.Should().NotBeNull();
|
result.First().ImportDecision.Should().NotBeNull();
|
||||||
result.First().ImportDecision.LocalEpisode.Should().NotBeNull();
|
result.First().ImportDecision.LocalTrack.Should().NotBeNull();
|
||||||
result.First().ImportDecision.LocalEpisode.Path.Should().Be(fileName);
|
result.First().ImportDecision.LocalTrack.Path.Should().Be(fileName);
|
||||||
result.First().Result.Should().Be(ImportResultType.Rejected);
|
result.First().Result.Should().Be(ImportResultType.Rejected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,13 +222,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenValidSeries();
|
GivenValidSeries();
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
@ -271,7 +273,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, SearchOption.TopDirectoryOnly))
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.GetFiles(folderName, SearchOption.TopDirectoryOnly))
|
||||||
.Returns(new[] { fileName });
|
.Returns(new[] { fileName });
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
@ -280,7 +282,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.ProcessPath(fileName);
|
Subject.ProcessPath(fileName);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(v => v.AbsoluteEpisodeNumbers.First() == 9), true), Times.Once());
|
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), It.Is<ParsedTrackInfo>(v => v.TrackNumbers.First() == 9)), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -296,7 +298,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(fileName))
|
Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(fileName))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
@ -304,7 +306,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
var result = Subject.ProcessPath(fileName);
|
var result = Subject.ProcessPath(fileName);
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), null, true), Times.Once());
|
.Verify(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -331,13 +333,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenValidSeries();
|
GivenValidSeries();
|
||||||
|
|
||||||
var localEpisode = new LocalEpisode();
|
var localEpisode = new LocalTrack();
|
||||||
|
|
||||||
var imported = new List<ImportDecision>();
|
var imported = new List<ImportDecision>();
|
||||||
imported.Add(new ImportDecision(localEpisode));
|
imported.Add(new ImportDecision(localEpisode));
|
||||||
|
|
||||||
Mocker.GetMock<IMakeImportDecision>()
|
Mocker.GetMock<IMakeImportDecision>()
|
||||||
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Series>(), null, true))
|
.Setup(s => s.GetImportDecisions(It.IsAny<List<string>>(), It.IsAny<Artist>(), null))
|
||||||
.Returns(imported);
|
.Returns(imported);
|
||||||
|
|
||||||
Mocker.GetMock<IImportApprovedEpisodes>()
|
Mocker.GetMock<IImportApprovedEpisodes>()
|
||||||
|
|
|
@ -11,7 +11,7 @@ using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Profiles;
|
using NzbDrone.Core.Profiles;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ImportDecisionMakerFixture : CoreTest<ImportDecisionMaker>
|
public class ImportDecisionMakerFixture : CoreTest<ImportDecisionMaker>
|
||||||
{
|
{
|
||||||
private List<string> _videoFiles;
|
private List<string> _audioFiles;
|
||||||
private LocalEpisode _localEpisode;
|
private LocalTrack _localTrack;
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
private QualityModel _quality;
|
private QualityModel _quality;
|
||||||
|
|
||||||
private Mock<IImportDecisionEngineSpecification> _pass1;
|
private Mock<IImportDecisionEngineSpecification> _pass1;
|
||||||
|
@ -44,31 +44,31 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
_fail2 = new Mock<IImportDecisionEngineSpecification>();
|
_fail2 = new Mock<IImportDecisionEngineSpecification>();
|
||||||
_fail3 = new Mock<IImportDecisionEngineSpecification>();
|
_fail3 = new Mock<IImportDecisionEngineSpecification>();
|
||||||
|
|
||||||
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
_pass1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
|
||||||
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
_pass2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
|
||||||
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Accept());
|
_pass3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Accept());
|
||||||
|
|
||||||
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail1"));
|
_fail1.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail1"));
|
||||||
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail2"));
|
_fail2.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail2"));
|
||||||
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalEpisode>())).Returns(Decision.Reject("_fail3"));
|
_fail3.Setup(c => c.IsSatisfiedBy(It.IsAny<LocalTrack>())).Returns(Decision.Reject("_fail3"));
|
||||||
|
|
||||||
_series = Builder<Series>.CreateNew()
|
_artist = Builder<Artist>.CreateNew()
|
||||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_quality = new QualityModel(Quality.MP3256);
|
_quality = new QualityModel(Quality.MP3256);
|
||||||
|
|
||||||
_localEpisode = new LocalEpisode
|
_localTrack = new LocalTrack
|
||||||
{
|
{
|
||||||
Series = _series,
|
Artist = _artist,
|
||||||
Quality = _quality,
|
Quality = _quality,
|
||||||
Episodes = new List<Episode> { new Episode() },
|
Tracks = new List<Track> { new Track() },
|
||||||
Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi"
|
Path = @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi"
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
.Setup(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()))
|
||||||
.Returns(_localEpisode);
|
.Returns(_localTrack);
|
||||||
|
|
||||||
GivenVideoFiles(new List<string> { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() });
|
GivenVideoFiles(new List<string> { @"C:\Test\Unsorted\The.Office.S03E115.DVDRip.XviD-OSiTV.avi".AsOsAgnostic() });
|
||||||
}
|
}
|
||||||
|
@ -80,11 +80,11 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
|
|
||||||
private void GivenVideoFiles(IEnumerable<string> videoFiles)
|
private void GivenVideoFiles(IEnumerable<string> videoFiles)
|
||||||
{
|
{
|
||||||
_videoFiles = videoFiles.ToList();
|
_audioFiles = videoFiles.ToList();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(c => c.FilterExistingFiles(_videoFiles, It.IsAny<Series>()))
|
.Setup(c => c.FilterExistingFiles(_audioFiles, It.IsAny<Artist>()))
|
||||||
.Returns(_videoFiles);
|
.Returns(_audioFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -92,14 +92,14 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, new Series(), null, false);
|
Subject.GetImportDecisions(_audioFiles, new Artist(), null);
|
||||||
|
|
||||||
_fail1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_fail1.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
_fail2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_fail2.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
_fail3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_fail3.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
_pass1.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_pass1.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
_pass2.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_pass2.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
_pass3.Verify(c => c.IsSatisfiedBy(_localEpisode), Times.Once());
|
_pass3.Verify(c => c.IsSatisfiedBy(_localTrack), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_fail1);
|
GivenSpecifications(_fail1);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
var result = Subject.GetImportDecisions(_audioFiles, new Artist());
|
||||||
|
|
||||||
result.Single().Approved.Should().BeFalse();
|
result.Single().Approved.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _fail1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _fail1, _pass2, _pass3);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
var result = Subject.GetImportDecisions(_audioFiles, new Artist());
|
||||||
|
|
||||||
result.Single().Approved.Should().BeFalse();
|
result.Single().Approved.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
var result = Subject.GetImportDecisions(_audioFiles, new Artist());
|
||||||
|
|
||||||
result.Single().Approved.Should().BeTrue();
|
result.Single().Approved.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
GivenSpecifications(_pass1, _pass2, _pass3, _fail1, _fail2, _fail3);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, new Series());
|
var result = Subject.GetImportDecisions(_audioFiles, new Artist());
|
||||||
result.Single().Rejections.Should().HaveCount(3);
|
result.Single().Rejections.Should().HaveCount(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,22 +147,22 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
.Setup(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()))
|
||||||
.Throws<TestException>();
|
.Throws<TestException>();
|
||||||
|
|
||||||
_videoFiles = new List<string>
|
_audioFiles = new List<string>
|
||||||
{
|
{
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenVideoFiles(_videoFiles);
|
GivenVideoFiles(_audioFiles);
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series);
|
Subject.GetImportDecisions(_audioFiles, _artist);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()), Times.Exactly(_audioFiles.Count));
|
||||||
|
|
||||||
ExceptionVerification.ExpectedErrors(3);
|
ExceptionVerification.ExpectedErrors(3);
|
||||||
}
|
}
|
||||||
|
@ -171,22 +171,22 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
public void should_use_file_quality_if_folder_quality_is_null()
|
public void should_use_file_quality_if_folder_quality_is_null()
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single());
|
var expectedQuality = QualityParser.ParseQuality(_audioFiles.Single());
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, _series);
|
var result = Subject.GetImportDecisions(_audioFiles, _artist);
|
||||||
|
|
||||||
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
result.Single().LocalTrack.Quality.Should().Be(expectedQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_use_file_quality_if_file_quality_was_determined_by_name()
|
public void should_use_file_quality_if_file_quality_was_determined_by_name()
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
var expectedQuality = QualityParser.ParseQuality(_videoFiles.Single());
|
var expectedQuality = QualityParser.ParseQuality(_audioFiles.Single());
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo{Quality = new QualityModel(Quality.MP3256) }, true);
|
var result = Subject.GetImportDecisions(_audioFiles, _artist, new ParsedTrackInfo{Quality = new QualityModel(Quality.MP3256) });
|
||||||
|
|
||||||
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
result.Single().LocalTrack.Quality.Should().Be(expectedQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -195,15 +195,15 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
|
GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
|
||||||
|
|
||||||
_localEpisode.Path = _videoFiles.Single();
|
_localTrack.Path = _audioFiles.Single();
|
||||||
_localEpisode.Quality.QualitySource = QualitySource.Extension;
|
_localTrack.Quality.QualitySource = QualitySource.Extension;
|
||||||
_localEpisode.Quality.Quality = Quality.MP3256;
|
_localTrack.Quality.Quality = Quality.MP3256;
|
||||||
|
|
||||||
var expectedQuality = new QualityModel(Quality.MP3256);
|
var expectedQuality = new QualityModel(Quality.MP3256);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true);
|
var result = Subject.GetImportDecisions(_audioFiles, _artist, new ParsedTrackInfo { Quality = expectedQuality });
|
||||||
|
|
||||||
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
result.Single().LocalTrack.Quality.Should().Be(expectedQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -212,14 +212,14 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
|
GivenVideoFiles(new string[] { @"C:\Test\Unsorted\The.Office.S03E115.mkv".AsOsAgnostic() });
|
||||||
|
|
||||||
_localEpisode.Path = _videoFiles.Single();
|
_localTrack.Path = _audioFiles.Single();
|
||||||
_localEpisode.Quality.Quality = Quality.MP3256;
|
_localTrack.Quality.Quality = Quality.MP3256;
|
||||||
|
|
||||||
var expectedQuality = new QualityModel(Quality.MP3256);
|
var expectedQuality = new QualityModel(Quality.MP3256);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = expectedQuality }, true);
|
var result = Subject.GetImportDecisions(_audioFiles, _artist, new ParsedTrackInfo { Quality = expectedQuality });
|
||||||
|
|
||||||
result.Single().LocalEpisode.Quality.Should().Be(expectedQuality);
|
result.Single().LocalTrack.Quality.Should().Be(expectedQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -228,22 +228,22 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
.Setup(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()))
|
||||||
.Returns(new LocalEpisode() { Path = "test" });
|
.Returns(new LocalTrack() { Path = "test" });
|
||||||
|
|
||||||
_videoFiles = new List<string>
|
_audioFiles = new List<string>
|
||||||
{
|
{
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
"The.Office.S03E115.DVDRip.XviD-OSiTV",
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenVideoFiles(_videoFiles);
|
GivenVideoFiles(_audioFiles);
|
||||||
|
|
||||||
var decisions = Subject.GetImportDecisions(_videoFiles, _series);
|
var decisions = Subject.GetImportDecisions(_audioFiles, _artist);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()), Times.Exactly(_videoFiles.Count));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()), Times.Exactly(_audioFiles.Count));
|
||||||
|
|
||||||
decisions.Should().HaveCount(3);
|
decisions.Should().HaveCount(3);
|
||||||
decisions.First().Rejections.Should().NotBeEmpty();
|
decisions.First().Rejections.Should().NotBeEmpty();
|
||||||
|
@ -254,23 +254,23 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
var videoFiles = new[]
|
var videoFiles = new[]
|
||||||
{
|
{
|
||||||
@"C:\Test\Unsorted\Series.Title.S01\S01E01.mkv".AsOsAgnostic(),
|
@"C:\Test\Unsorted\Artist.Title.S01\S01E01.mkv".AsOsAgnostic(),
|
||||||
@"C:\Test\Unsorted\Series.Title.S01\S01E02.mkv".AsOsAgnostic(),
|
@"C:\Test\Unsorted\Artist.Title.S01\S01E02.mkv".AsOsAgnostic(),
|
||||||
@"C:\Test\Unsorted\Series.Title.S01\S01E03.mkv".AsOsAgnostic()
|
@"C:\Test\Unsorted\Artist.Title.S01\S01E03.mkv".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
GivenVideoFiles(videoFiles);
|
GivenVideoFiles(videoFiles);
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01");
|
var folderInfo = Parser.Parser.ParseMusicTitle("Artist.Title.S01");
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
Subject.GetImportDecisions(_audioFiles, _artist, folderInfo);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(3));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), null), Times.Exactly(3));
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.Is<ParsedTrackInfo>(p => p != null)), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -278,22 +278,22 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
var videoFiles = new[]
|
var videoFiles = new[]
|
||||||
{
|
{
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(),
|
@"C:\Test\Unsorted\Artist.Title.S01E01\S01E01.mkv".AsOsAgnostic(),
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01\1x01.mkv".AsOsAgnostic()
|
@"C:\Test\Unsorted\Artist.Title.S01E01\1x01.mkv".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
GivenVideoFiles(videoFiles);
|
GivenVideoFiles(videoFiles);
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
var folderInfo = Parser.Parser.ParseMusicTitle("Artist.Title.S01E01");
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
Subject.GetImportDecisions(_audioFiles, _artist, folderInfo);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(2));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), null), Times.Exactly(2));
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.Is<ParsedTrackInfo>(p => p != null)), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -301,70 +301,70 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
var videoFiles = new[]
|
var videoFiles = new[]
|
||||||
{
|
{
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic()
|
@"C:\Test\Unsorted\Artist.Title.S01E01\S01E01.mkv".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
GivenVideoFiles(videoFiles);
|
GivenVideoFiles(videoFiles);
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
var folderInfo = Parser.Parser.ParseMusicTitle("Artist.Title.S01E01");
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
Subject.GetImportDecisions(_audioFiles, _artist, folderInfo);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), true), Times.Exactly(1));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()), Times.Exactly(1));
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Never());
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), null), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
//[Test]
|
||||||
public void should_use_folder_when_only_one_video_file_and_a_sample()
|
//public void should_use_folder_when_only_one_video_file_and_a_sample() /// WE DONT HAVE SAMPLES IN MUSIC
|
||||||
{
|
//{
|
||||||
var videoFiles = new[]
|
// var audioFiles = new[]
|
||||||
{
|
// {
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.mkv".AsOsAgnostic(),
|
// @"C:\Test\Unsorted\Artist.Name.S01E01\S01E01.mkv".AsOsAgnostic(),
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01\S01E01.sample.mkv".AsOsAgnostic()
|
// @"C:\Test\Unsorted\Artist.Name.S01E01\S01E01.sample.mkv".AsOsAgnostic()
|
||||||
};
|
// };
|
||||||
|
|
||||||
GivenSpecifications(_pass1);
|
// GivenSpecifications(_pass1);
|
||||||
GivenVideoFiles(videoFiles.ToList());
|
// GivenVideoFiles(audioFiles.ToList());
|
||||||
|
|
||||||
Mocker.GetMock<IDetectSample>()
|
// Mocker.GetMock<IDetectSample>()
|
||||||
.Setup(s => s.IsSample(_series, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<bool>()))
|
// .Setup(s => s.IsSample(_artist, It.IsAny<QualityModel>(), It.Is<string>(c => c.Contains("sample")), It.IsAny<long>(), It.IsAny<bool>()))
|
||||||
.Returns(true);
|
// .Returns(true);
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01");
|
// var folderInfo = Parser.Parser.ParseMusicTitle("Artist.Name.S01E01");
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
// Subject.GetImportDecisions(_audioFiles, _artist, folderInfo);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
// Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), true), Times.Exactly(2));
|
// .Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()), Times.Exactly(2));
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
// Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Never());
|
// .Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), null), Times.Never());
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_use_folder_name_if_file_name_is_scene_name()
|
public void should_not_use_folder_name_if_file_name_is_scene_name()
|
||||||
{
|
{
|
||||||
var videoFiles = new[]
|
var videoFiles = new[]
|
||||||
{
|
{
|
||||||
@"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-LOL\Series.Title.S01E01.720p.HDTV-LOL.mkv".AsOsAgnostic()
|
@"C:\Test\Unsorted\Artist.Title.S01E01.720p.HDTV-LOL\Artist.Title.S01E01.720p.HDTV-LOL.mkv".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenSpecifications(_pass1);
|
GivenSpecifications(_pass1);
|
||||||
GivenVideoFiles(videoFiles);
|
GivenVideoFiles(videoFiles);
|
||||||
|
|
||||||
var folderInfo = Parser.Parser.ParseTitle("Series.Title.S01E01.720p.HDTV-LOL");
|
var folderInfo = Parser.Parser.ParseMusicTitle("Artist.Title.S01E01.720p.HDTV-LOL");
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series, folderInfo, true);
|
Subject.GetImportDecisions(_audioFiles, _artist, folderInfo);
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), null, true), Times.Exactly(1));
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), null), Times.Exactly(1));
|
||||||
|
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Verify(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.Is<ParsedEpisodeInfo>(p => p != null), true), Times.Never());
|
.Verify(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.Is<ParsedTrackInfo>(p => p != null)), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -372,7 +372,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
{
|
{
|
||||||
GivenSpecifications(_pass1, _pass2, _pass3);
|
GivenSpecifications(_pass1, _pass2, _pass3);
|
||||||
|
|
||||||
_series.Profile = new Profile
|
_artist.Profile = new Profile
|
||||||
{
|
{
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3256, Quality.Unknown)
|
Items = Qualities.QualityFixture.GetDefaultQualities(Quality.MP3256, Quality.Unknown)
|
||||||
};
|
};
|
||||||
|
@ -380,26 +380,26 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
|
||||||
|
|
||||||
var folderQuality = new QualityModel(Quality.Unknown);
|
var folderQuality = new QualityModel(Quality.Unknown);
|
||||||
|
|
||||||
var result = Subject.GetImportDecisions(_videoFiles, _series, new ParsedEpisodeInfo { Quality = folderQuality}, true);
|
var result = Subject.GetImportDecisions(_audioFiles, _artist, new ParsedTrackInfo { Quality = folderQuality});
|
||||||
|
|
||||||
result.Single().LocalEpisode.Quality.Should().Be(_quality);
|
result.Single().LocalTrack.Quality.Should().Be(_quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_a_decision_when_exception_is_caught()
|
public void should_return_a_decision_when_exception_is_caught()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IParsingService>()
|
Mocker.GetMock<IParsingService>()
|
||||||
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
|
.Setup(c => c.GetLocalTrack(It.IsAny<string>(), It.IsAny<Artist>(), It.IsAny<ParsedTrackInfo>()))
|
||||||
.Throws<TestException>();
|
.Throws<TestException>();
|
||||||
|
|
||||||
_videoFiles = new List<string>
|
_audioFiles = new List<string>
|
||||||
{
|
{
|
||||||
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
"The.Office.S03E115.DVDRip.XviD-OSiTV"
|
||||||
};
|
};
|
||||||
|
|
||||||
GivenVideoFiles(_videoFiles);
|
GivenVideoFiles(_audioFiles);
|
||||||
|
|
||||||
Subject.GetImportDecisions(_videoFiles, _series).Should().HaveCount(1);
|
Subject.GetImportDecisions(_audioFiles, _artist).Should().HaveCount(1);
|
||||||
|
|
||||||
ExceptionVerification.ExpectedErrors(1);
|
ExceptionVerification.ExpectedErrors(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,20 +8,20 @@ using NUnit.Framework;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MediaFiles.EpisodeImport;
|
using NzbDrone.Core.MediaFiles.TrackImport;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Profiles;
|
using NzbDrone.Core.Profiles;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ImportApprovedEpisodesFixture : CoreTest<ImportApprovedEpisodes>
|
public class ImportApprovedEpisodesFixture : CoreTest<ImportApprovedTracks>
|
||||||
{
|
{
|
||||||
private List<ImportDecision> _rejectedDecisions;
|
private List<ImportDecision> _rejectedDecisions;
|
||||||
private List<ImportDecision> _approvedDecisions;
|
private List<ImportDecision> _approvedDecisions;
|
||||||
|
@ -34,31 +34,31 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
_rejectedDecisions = new List<ImportDecision>();
|
_rejectedDecisions = new List<ImportDecision>();
|
||||||
_approvedDecisions = new List<ImportDecision>();
|
_approvedDecisions = new List<ImportDecision>();
|
||||||
|
|
||||||
var series = Builder<Series>.CreateNew()
|
var artist = Builder<Artist>.CreateNew()
|
||||||
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
.With(e => e.Profile = new Profile { Items = Qualities.QualityFixture.GetDefaultQualities() })
|
||||||
.With(s => s.Path = @"C:\Test\TV\30 Rock".AsOsAgnostic())
|
.With(s => s.Path = @"C:\Test\Music\Alien Ant Farm".AsOsAgnostic())
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var episodes = Builder<Episode>.CreateListOfSize(5)
|
var tracks = Builder<Track>.CreateListOfSize(5)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!")));
|
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||||
_rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!")));
|
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||||
_rejectedDecisions.Add(new ImportDecision(new LocalEpisode(), new Rejection("Rejected!")));
|
_rejectedDecisions.Add(new ImportDecision(new LocalTrack(), new Rejection("Rejected!")));
|
||||||
|
|
||||||
foreach (var episode in episodes)
|
foreach (var track in tracks)
|
||||||
{
|
{
|
||||||
_approvedDecisions.Add(new ImportDecision
|
_approvedDecisions.Add(new ImportDecision
|
||||||
(
|
(
|
||||||
new LocalEpisode
|
new LocalTrack
|
||||||
{
|
{
|
||||||
Series = series,
|
Artist = artist,
|
||||||
Episodes = new List<Episode> { episode },
|
Tracks = new List<Track> { track },
|
||||||
Path = Path.Combine(series.Path, "30 Rock - S01E01 - Pilot.avi"),
|
Path = Path.Combine(artist.Path, "30 Rock - S01E01 - Pilot.avi"),
|
||||||
Quality = new QualityModel(Quality.MP3256),
|
Quality = new QualityModel(Quality.MP3256),
|
||||||
ParsedEpisodeInfo = new ParsedEpisodeInfo
|
ParsedTrackInfo = new ParsedTrackInfo
|
||||||
{
|
{
|
||||||
ReleaseGroup = "DRONE"
|
ReleaseGroup = "DRONE"
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||||
.Setup(s => s.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), It.IsAny<LocalEpisode>(), It.IsAny<bool>()))
|
.Setup(s => s.UpgradeTrackFile(It.IsAny<TrackFile>(), It.IsAny<LocalTrack>(), It.IsAny<bool>()))
|
||||||
.Returns(new EpisodeFileMoveResult());
|
.Returns(new TrackFileMoveResult());
|
||||||
|
|
||||||
_downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
|
_downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
Subject.Import(_rejectedDecisions, false).Where(i => i.Result == ImportResultType.Imported).Should().BeEmpty();
|
Subject.Import(_rejectedDecisions, false).Where(i => i.Result == ImportResultType.Imported).Should().BeEmpty();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.IsAny<EpisodeFile>()), Times.Never());
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.IsAny<TrackFile>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
var all = new List<ImportDecision>();
|
var all = new List<ImportDecision>();
|
||||||
all.AddRange(_approvedDecisions);
|
all.AddRange(_approvedDecisions);
|
||||||
all.Add(new ImportDecision(_approvedDecisions.First().LocalEpisode));
|
all.Add(new ImportDecision(_approvedDecisions.First().LocalTrack));
|
||||||
|
|
||||||
var result = Subject.Import(all, false);
|
var result = Subject.Import(all, false);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||||
|
|
||||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false),
|
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false),
|
||||||
Times.Once());
|
Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, false);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, false);
|
||||||
|
|
||||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false),
|
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false),
|
||||||
Times.Never());
|
Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == _downloadClientItem.Title)));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<TrackFile>(c => c.SceneName == _downloadClientItem.Title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(".mkv")]
|
[TestCase(".mkv")]
|
||||||
|
@ -161,51 +161,51 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == title)));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<TrackFile>(c => c.SceneName == title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_use_nzb_title_as_scene_name_if_full_season()
|
public void should_not_use_nzb_title_as_scene_name_if_full_season()
|
||||||
{
|
{
|
||||||
_approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\season1\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
_approvedDecisions.First().LocalTrack.Path = "c:\\tv\\season1\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
||||||
_downloadClientItem.Title = "malcolm.in.the.middle.s02.dvdrip.xvid-ingot";
|
_downloadClientItem.Title = "malcolm.in.the.middle.s02.dvdrip.xvid-ingot";
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, _downloadClientItem);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot")));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<TrackFile>(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot")));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename()
|
public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename()
|
||||||
{
|
{
|
||||||
_approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
_approvedDecisions.First().LocalTrack.Path = "c:\\tv\\malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv".AsOsAgnostic();
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot")));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<TrackFile>(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot")));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenename()
|
public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenename()
|
||||||
{
|
{
|
||||||
_approvedDecisions.First().LocalEpisode.Path = "c:\\tv\\aaaaa.mkv".AsOsAgnostic();
|
_approvedDecisions.First().LocalTrack.Path = "c:\\tv\\aaaaa.mkv".AsOsAgnostic();
|
||||||
|
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<EpisodeFile>(c => c.SceneName == null)));
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Add(It.Is<TrackFile>(c => c.SceneName == null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_import_larger_files_first()
|
public void should_import_larger_files_first()
|
||||||
{
|
{
|
||||||
var fileDecision = _approvedDecisions.First();
|
var fileDecision = _approvedDecisions.First();
|
||||||
fileDecision.LocalEpisode.Size = 1.Gigabytes();
|
fileDecision.LocalTrack.Size = 1.Gigabytes();
|
||||||
|
|
||||||
var sampleDecision = new ImportDecision
|
var sampleDecision = new ImportDecision
|
||||||
(new LocalEpisode
|
(new LocalTrack
|
||||||
{
|
{
|
||||||
Series = fileDecision.LocalEpisode.Series,
|
Artist = fileDecision.LocalTrack.Artist,
|
||||||
Episodes = new List<Episode> { fileDecision.LocalEpisode.Episodes.First() },
|
Tracks = new List<Track> { fileDecision.LocalTrack.Tracks.First() },
|
||||||
Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(),
|
Path = @"C:\Test\TV\30 Rock\30 Rock - S01E01 - Pilot.avi".AsOsAgnostic(),
|
||||||
Quality = new QualityModel(Quality.MP3256),
|
Quality = new QualityModel(Quality.MP3256),
|
||||||
Size = 80.Megabytes()
|
Size = 80.Megabytes()
|
||||||
|
@ -220,7 +220,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
results.Should().HaveCount(all.Count);
|
results.Should().HaveCount(all.Count);
|
||||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported);
|
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported);
|
||||||
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.LocalEpisode.Size == fileDecision.LocalEpisode.Size);
|
results.Should().ContainSingle(d => d.Result == ImportResultType.Imported && d.ImportDecision.LocalTrack.Size == fileDecision.LocalTrack.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -229,7 +229,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true });
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true });
|
||||||
|
|
||||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, true), Times.Once());
|
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, true), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -238,7 +238,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }, ImportMode.Move);
|
Subject.Import(new List<ImportDecision> { _approvedDecisions.First() }, true, new DownloadClientItem { Title = "30.Rock.S01E01", IsReadOnly = true }, ImportMode.Move);
|
||||||
|
|
||||||
Mocker.GetMock<IUpgradeMediaFiles>()
|
Mocker.GetMock<IUpgradeMediaFiles>()
|
||||||
.Verify(v => v.UpgradeEpisodeFile(It.IsAny<EpisodeFile>(), _approvedDecisions.First().LocalEpisode, false), Times.Once());
|
.Verify(v => v.UpgradeTrackFile(It.IsAny<TrackFile>(), _approvedDecisions.First().LocalTrack, false), Times.Once());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,26 +8,26 @@ using NzbDrone.Core.Test.Framework;
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MediaFileRepositoryFixture : DbTest<MediaFileRepository, EpisodeFile>
|
public class MediaFileRepositoryFixture : DbTest<MediaFileRepository, TrackFile>
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void get_files_by_series()
|
public void get_files_by_series()
|
||||||
{
|
{
|
||||||
var files = Builder<EpisodeFile>.CreateListOfSize(10)
|
var files = Builder<TrackFile>.CreateListOfSize(10)
|
||||||
.All()
|
.All()
|
||||||
.With(c => c.Id = 0)
|
.With(c => c.Id = 0)
|
||||||
.With(c => c.Quality =new QualityModel(Quality.MP3192))
|
.With(c => c.Quality =new QualityModel(Quality.MP3192))
|
||||||
.Random(4)
|
.Random(4)
|
||||||
.With(s => s.SeriesId = 12)
|
.With(s => s.ArtistId = 12)
|
||||||
.BuildListOfNew();
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
|
||||||
Db.InsertMany(files);
|
Db.InsertMany(files);
|
||||||
|
|
||||||
var seriesFiles = Subject.GetFilesBySeries(12);
|
var seriesFiles = Subject.GetFilesByArtist(12);
|
||||||
|
|
||||||
seriesFiles.Should().HaveCount(4);
|
seriesFiles.Should().HaveCount(4);
|
||||||
seriesFiles.Should().OnlyContain(c => c.SeriesId == 12);
|
seriesFiles.Should().OnlyContain(c => c.ArtistId == 12);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
@ -7,6 +7,7 @@ using NUnit.Framework;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
|
@ -14,12 +15,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FilterFixture : CoreTest<MediaFileService>
|
public class FilterFixture : CoreTest<MediaFileService>
|
||||||
{
|
{
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_series = new Series
|
_artist = new Artist
|
||||||
{
|
{
|
||||||
Id = 10,
|
Id = 10,
|
||||||
Path = @"C:\".AsOsAgnostic()
|
Path = @"C:\".AsOsAgnostic()
|
||||||
|
@ -37,11 +38,11 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(new List<EpisodeFile>());
|
.Returns(new List<TrackFile>());
|
||||||
|
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().BeEquivalentTo(files);
|
Subject.FilterExistingFiles(files, _artist).Should().BeEquivalentTo(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -55,11 +56,11 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(files.Select(f => new EpisodeFile { RelativePath = Path.GetFileName(f) }).ToList());
|
.Returns(files.Select(f => new TrackFile { RelativePath = Path.GetFileName(f) }).ToList());
|
||||||
|
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().BeEmpty();
|
Subject.FilterExistingFiles(files, _artist).Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -73,15 +74,15 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(new List<EpisodeFile>
|
.Returns(new List<TrackFile>
|
||||||
{
|
{
|
||||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
new TrackFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(2);
|
Subject.FilterExistingFiles(files, _artist).Should().HaveCount(2);
|
||||||
Subject.FilterExistingFiles(files, _series).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
Subject.FilterExistingFiles(files, _artist).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -97,15 +98,15 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(new List<EpisodeFile>
|
.Returns(new List<TrackFile>
|
||||||
{
|
{
|
||||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
new TrackFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(2);
|
Subject.FilterExistingFiles(files, _artist).Should().HaveCount(2);
|
||||||
Subject.FilterExistingFiles(files, _series).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
Subject.FilterExistingFiles(files, _artist).Should().NotContain("C:\\file2.avi".AsOsAgnostic());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -121,13 +122,13 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(new List<EpisodeFile>
|
.Returns(new List<TrackFile>
|
||||||
{
|
{
|
||||||
new EpisodeFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
new TrackFile{ RelativePath = "file2.avi".AsOsAgnostic()}
|
||||||
});
|
});
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(3);
|
Subject.FilterExistingFiles(files, _artist).Should().HaveCount(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -139,12 +140,12 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaFileServiceTests
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileRepository>()
|
Mocker.GetMock<IMediaFileRepository>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(new List<EpisodeFile>());
|
.Returns(new List<TrackFile>());
|
||||||
|
|
||||||
Subject.FilterExistingFiles(files, _series).Should().HaveCount(1);
|
Subject.FilterExistingFiles(files, _artist).Should().HaveCount(1);
|
||||||
Subject.FilterExistingFiles(files, _series).Should().NotContain(files.First().ToLower());
|
Subject.FilterExistingFiles(files, _artist).Should().NotContain(files.First().ToLower());
|
||||||
Subject.FilterExistingFiles(files, _series).Should().Contain(files.First());
|
Subject.FilterExistingFiles(files, _artist).Should().Contain(files.First());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ using NUnit.Framework;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.MediaFiles;
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
@ -15,117 +15,117 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
public class MediaFileTableCleanupServiceFixture : CoreTest<MediaFileTableCleanupService>
|
public class MediaFileTableCleanupServiceFixture : CoreTest<MediaFileTableCleanupService>
|
||||||
{
|
{
|
||||||
private const string DELETED_PATH = "ANY FILE WITH THIS PATH IS CONSIDERED DELETED!";
|
private const string DELETED_PATH = "ANY FILE WITH THIS PATH IS CONSIDERED DELETED!";
|
||||||
private List<Episode> _episodes;
|
private List<Track> _tracks;
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
_episodes = Builder<Episode>.CreateListOfSize(10)
|
_tracks = Builder<Track>.CreateListOfSize(10)
|
||||||
.Build()
|
.Build()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
_series = Builder<Series>.CreateNew()
|
_artist = Builder<Artist>.CreateNew()
|
||||||
.With(s => s.Path = @"C:\Test\TV\Series".AsOsAgnostic())
|
.With(s => s.Path = @"C:\Test\Music\Artist".AsOsAgnostic())
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(e => e.FileExists(It.Is<string>(c => !c.Contains(DELETED_PATH))))
|
.Setup(e => e.FileExists(It.Is<string>(c => !c.Contains(DELETED_PATH))))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<ITrackService>()
|
||||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetTracksByArtist(It.IsAny<int>()))
|
||||||
.Returns(_episodes);
|
.Returns(_tracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenEpisodeFiles(IEnumerable<EpisodeFile> episodeFiles)
|
private void GivenTrackFiles(IEnumerable<TrackFile> trackFiles)
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(c => c.GetFilesBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetFilesByArtist(It.IsAny<int>()))
|
||||||
.Returns(episodeFiles.ToList());
|
.Returns(trackFiles.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenFilesAreNotAttachedToEpisode()
|
private void GivenFilesAreNotAttachedToTrack()
|
||||||
{
|
{
|
||||||
_episodes.ForEach(e => e.EpisodeFileId = 0);
|
_tracks.ForEach(e => e.TrackFileId = 0);
|
||||||
|
|
||||||
Mocker.GetMock<IEpisodeService>()
|
Mocker.GetMock<ITrackService>()
|
||||||
.Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
|
.Setup(c => c.GetTracksByArtist(It.IsAny<int>()))
|
||||||
.Returns(_episodes);
|
.Returns(_tracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> FilesOnDisk(IEnumerable<EpisodeFile> episodeFiles)
|
private List<string> FilesOnDisk(IEnumerable<TrackFile> trackFiles)
|
||||||
{
|
{
|
||||||
return episodeFiles.Select(e => Path.Combine(_series.Path, e.RelativePath)).ToList();
|
return trackFiles.Select(e => Path.Combine(_artist.Path, e.RelativePath)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_skip_files_that_exist_in_disk()
|
public void should_skip_files_that_exist_in_disk()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(10)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
GivenEpisodeFiles(episodeFiles);
|
GivenTrackFiles(trackFiles);
|
||||||
|
|
||||||
Subject.Clean(_series, FilesOnDisk(episodeFiles));
|
Subject.Clean(_artist, FilesOnDisk(trackFiles));
|
||||||
|
|
||||||
Mocker.GetMock<IEpisodeService>().Verify(c => c.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
Mocker.GetMock<ITrackService>().Verify(c => c.UpdateTrack(It.IsAny<Track>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_non_existent_files()
|
public void should_delete_non_existent_files()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(10)
|
||||||
.Random(2)
|
.Random(2)
|
||||||
.With(c => c.RelativePath = DELETED_PATH)
|
.With(c => c.RelativePath = DELETED_PATH)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
GivenEpisodeFiles(episodeFiles);
|
GivenTrackFiles(trackFiles);
|
||||||
|
|
||||||
Subject.Clean(_series, FilesOnDisk(episodeFiles.Where(e => e.RelativePath != DELETED_PATH)));
|
Subject.Clean(_artist, FilesOnDisk(trackFiles.Where(e => e.RelativePath != DELETED_PATH)));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.Is<EpisodeFile>(e => e.RelativePath == DELETED_PATH), DeleteMediaFileReason.MissingFromDisk), Times.Exactly(2));
|
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.Is<TrackFile>(e => e.RelativePath == DELETED_PATH), DeleteMediaFileReason.MissingFromDisk), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_files_that_dont_belong_to_any_episodes()
|
public void should_delete_files_that_dont_belong_to_any_episodes()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(10)
|
||||||
.Random(10)
|
.Random(10)
|
||||||
.With(c => c.RelativePath = "ExistingPath")
|
.With(c => c.RelativePath = "ExistingPath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
GivenEpisodeFiles(episodeFiles);
|
GivenTrackFiles(trackFiles);
|
||||||
GivenFilesAreNotAttachedToEpisode();
|
GivenFilesAreNotAttachedToTrack();
|
||||||
|
|
||||||
Subject.Clean(_series, FilesOnDisk(episodeFiles));
|
Subject.Clean(_artist, FilesOnDisk(trackFiles));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.IsAny<EpisodeFile>(), DeleteMediaFileReason.NoLinkedEpisodes), Times.Exactly(10));
|
Mocker.GetMock<IMediaFileService>().Verify(c => c.Delete(It.IsAny<TrackFile>(), DeleteMediaFileReason.NoLinkedEpisodes), Times.Exactly(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_unlink_episode_when_episodeFile_does_not_exist()
|
public void should_unlink_episode_when_episodeFile_does_not_exist()
|
||||||
{
|
{
|
||||||
GivenEpisodeFiles(new List<EpisodeFile>());
|
GivenTrackFiles(new List<TrackFile>());
|
||||||
|
|
||||||
Subject.Clean(_series, new List<string>());
|
Subject.Clean(_artist, new List<string>());
|
||||||
|
|
||||||
Mocker.GetMock<IEpisodeService>().Verify(c => c.UpdateEpisode(It.Is<Episode>(e => e.EpisodeFileId == 0)), Times.Exactly(10));
|
Mocker.GetMock<ITrackService>().Verify(c => c.UpdateTrack(It.Is<Track>(e => e.TrackFileId == 0)), Times.Exactly(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_update_episode_when_episodeFile_exists()
|
public void should_not_update_track_when_trackFile_exists()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(10)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(10)
|
||||||
.Random(10)
|
.Random(10)
|
||||||
.With(c => c.RelativePath = "ExistingPath")
|
.With(c => c.RelativePath = "ExistingPath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
GivenEpisodeFiles(episodeFiles);
|
GivenTrackFiles(trackFiles);
|
||||||
|
|
||||||
Subject.Clean(_series, FilesOnDisk(episodeFiles));
|
Subject.Clean(_artist, FilesOnDisk(trackFiles));
|
||||||
|
|
||||||
Mocker.GetMock<IEpisodeService>().Verify(c => c.UpdateEpisode(It.IsAny<Episode>()), Times.Never());
|
Mocker.GetMock<ITrackService>().Verify(c => c.UpdateTrack(It.IsAny<Track>()), Times.Never());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
|
@ -16,15 +17,15 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class UpdateMediaInfoServiceFixture : CoreTest<UpdateMediaInfoService>
|
public class UpdateMediaInfoServiceFixture : CoreTest<UpdateMediaInfoService>
|
||||||
{
|
{
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_series = new Series
|
_artist = new Artist
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
Path = @"C:\series".AsOsAgnostic()
|
Path = @"C:\artist".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
Mocker.GetMock<IConfigService>()
|
Mocker.GetMock<IConfigService>()
|
||||||
|
@ -56,7 +57,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||||
[Test]
|
[Test]
|
||||||
public void should_skip_up_to_date_media_info()
|
public void should_skip_up_to_date_media_info()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(3)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(3)
|
||||||
.All()
|
.All()
|
||||||
.With(v => v.RelativePath = "media.mkv")
|
.With(v => v.RelativePath = "media.mkv")
|
||||||
.TheFirst(1)
|
.TheFirst(1)
|
||||||
|
@ -64,25 +65,25 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||||
.BuildList();
|
.BuildList();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(v => v.GetFilesBySeries(1))
|
.Setup(v => v.GetFilesByArtist(1))
|
||||||
.Returns(episodeFiles);
|
.Returns(trackFiles);
|
||||||
|
|
||||||
GivenFileExists();
|
GivenFileExists();
|
||||||
GivenSuccessfulScan();
|
GivenSuccessfulScan();
|
||||||
|
|
||||||
Subject.Handle(new SeriesScannedEvent(_series));
|
Subject.Handle(new ArtistScannedEvent(_artist));
|
||||||
|
|
||||||
Mocker.GetMock<IVideoFileInfoReader>()
|
Mocker.GetMock<IVideoFileInfoReader>()
|
||||||
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(2));
|
.Verify(v => v.GetMediaInfo(Path.Combine(_artist.Path, "media.mkv")), Times.Exactly(2));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(2));
|
.Verify(v => v.Update(It.IsAny<TrackFile>()), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_update_outdated_media_info()
|
public void should_update_outdated_media_info()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(3)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(3)
|
||||||
.All()
|
.All()
|
||||||
.With(v => v.RelativePath = "media.mkv")
|
.With(v => v.RelativePath = "media.mkv")
|
||||||
.TheFirst(1)
|
.TheFirst(1)
|
||||||
|
@ -90,48 +91,48 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||||
.BuildList();
|
.BuildList();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(v => v.GetFilesBySeries(1))
|
.Setup(v => v.GetFilesByArtist(1))
|
||||||
.Returns(episodeFiles);
|
.Returns(trackFiles);
|
||||||
|
|
||||||
GivenFileExists();
|
GivenFileExists();
|
||||||
GivenSuccessfulScan();
|
GivenSuccessfulScan();
|
||||||
|
|
||||||
Subject.Handle(new SeriesScannedEvent(_series));
|
Subject.Handle(new ArtistScannedEvent(_artist));
|
||||||
|
|
||||||
Mocker.GetMock<IVideoFileInfoReader>()
|
Mocker.GetMock<IVideoFileInfoReader>()
|
||||||
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(3));
|
.Verify(v => v.GetMediaInfo(Path.Combine(_artist.Path, "media.mkv")), Times.Exactly(3));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(3));
|
.Verify(v => v.Update(It.IsAny<TrackFile>()), Times.Exactly(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_ignore_missing_files()
|
public void should_ignore_missing_files()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(2)
|
||||||
.All()
|
.All()
|
||||||
.With(v => v.RelativePath = "media.mkv")
|
.With(v => v.RelativePath = "media.mkv")
|
||||||
.BuildList();
|
.BuildList();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(v => v.GetFilesBySeries(1))
|
.Setup(v => v.GetFilesByArtist(1))
|
||||||
.Returns(episodeFiles);
|
.Returns(trackFiles);
|
||||||
|
|
||||||
GivenSuccessfulScan();
|
GivenSuccessfulScan();
|
||||||
|
|
||||||
Subject.Handle(new SeriesScannedEvent(_series));
|
Subject.Handle(new ArtistScannedEvent(_artist));
|
||||||
|
|
||||||
Mocker.GetMock<IVideoFileInfoReader>()
|
Mocker.GetMock<IVideoFileInfoReader>()
|
||||||
.Verify(v => v.GetMediaInfo("media.mkv"), Times.Never());
|
.Verify(v => v.GetMediaInfo("media.mkv"), Times.Never());
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Never());
|
.Verify(v => v.Update(It.IsAny<TrackFile>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_continue_after_failure()
|
public void should_continue_after_failure()
|
||||||
{
|
{
|
||||||
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
var trackFiles = Builder<TrackFile>.CreateListOfSize(2)
|
||||||
.All()
|
.All()
|
||||||
.With(v => v.RelativePath = "media.mkv")
|
.With(v => v.RelativePath = "media.mkv")
|
||||||
.TheFirst(1)
|
.TheFirst(1)
|
||||||
|
@ -139,20 +140,20 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
|
||||||
.BuildList();
|
.BuildList();
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(v => v.GetFilesBySeries(1))
|
.Setup(v => v.GetFilesByArtist(1))
|
||||||
.Returns(episodeFiles);
|
.Returns(trackFiles);
|
||||||
|
|
||||||
GivenFileExists();
|
GivenFileExists();
|
||||||
GivenSuccessfulScan();
|
GivenSuccessfulScan();
|
||||||
GivenFailedScan(Path.Combine(_series.Path, "media2.mkv"));
|
GivenFailedScan(Path.Combine(_artist.Path, "media2.mkv"));
|
||||||
|
|
||||||
Subject.Handle(new SeriesScannedEvent(_series));
|
Subject.Handle(new ArtistScannedEvent(_artist));
|
||||||
|
|
||||||
Mocker.GetMock<IVideoFileInfoReader>()
|
Mocker.GetMock<IVideoFileInfoReader>()
|
||||||
.Verify(v => v.GetMediaInfo(Path.Combine(_series.Path, "media.mkv")), Times.Exactly(1));
|
.Verify(v => v.GetMediaInfo(Path.Combine(_artist.Path, "media.mkv")), Times.Exactly(1));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(1));
|
.Verify(v => v.Update(It.IsAny<TrackFile>()), Times.Exactly(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,50 +9,50 @@ using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
public class RenameEpisodeFileServiceFixture : CoreTest<RenameEpisodeFileService>
|
public class RenameEpisodeFileServiceFixture : CoreTest<RenameEpisodeFileService>
|
||||||
{
|
{
|
||||||
private Series _series;
|
private Artist _artist;
|
||||||
private List<EpisodeFile> _episodeFiles;
|
private List<TrackFile> _trackFiles;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_series = Builder<Series>.CreateNew()
|
_artist = Builder<Artist>.CreateNew()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
_episodeFiles = Builder<EpisodeFile>.CreateListOfSize(2)
|
_trackFiles = Builder<TrackFile>.CreateListOfSize(2)
|
||||||
.All()
|
.All()
|
||||||
.With(e => e.SeriesId = _series.Id)
|
.With(e => e.ArtistId = _artist.Id)
|
||||||
.With(e => e.SeasonNumber = 1)
|
|
||||||
.Build()
|
.Build()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>()
|
Mocker.GetMock<IArtistService>()
|
||||||
.Setup(s => s.GetSeries(_series.Id))
|
.Setup(s => s.GetArtist(_artist.Id))
|
||||||
.Returns(_series);
|
.Returns(_artist);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenNoEpisodeFiles()
|
private void GivenNoEpisodeFiles()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(s => s.Get(It.IsAny<IEnumerable<int>>()))
|
.Setup(s => s.Get(It.IsAny<IEnumerable<int>>()))
|
||||||
.Returns(new List<EpisodeFile>());
|
.Returns(new List<TrackFile>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenEpisodeFiles()
|
private void GivenEpisodeFiles()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Setup(s => s.Get(It.IsAny<IEnumerable<int>>()))
|
.Setup(s => s.Get(It.IsAny<IEnumerable<int>>()))
|
||||||
.Returns(_episodeFiles);
|
.Returns(_trackFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenMovedFiles()
|
private void GivenMovedFiles()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<IMoveEpisodeFiles>()
|
Mocker.GetMock<IMoveTrackFiles>()
|
||||||
.Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), _series));
|
.Setup(s => s.MoveTrackFile(It.IsAny<TrackFile>(), _artist));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenNoEpisodeFiles();
|
GivenNoEpisodeFiles();
|
||||||
|
|
||||||
Subject.Execute(new RenameFilesCommand(_series.Id, new List<int>{1}));
|
Subject.Execute(new RenameFilesCommand(_artist.Id, new List<int>{1}));
|
||||||
|
|
||||||
Mocker.GetMock<IEventAggregator>()
|
Mocker.GetMock<IEventAggregator>()
|
||||||
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Never());
|
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Never());
|
||||||
|
@ -71,11 +71,11 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
GivenEpisodeFiles();
|
GivenEpisodeFiles();
|
||||||
|
|
||||||
Mocker.GetMock<IMoveEpisodeFiles>()
|
Mocker.GetMock<IMoveTrackFiles>()
|
||||||
.Setup(s => s.MoveEpisodeFile(It.IsAny<EpisodeFile>(), It.IsAny<Series>()))
|
.Setup(s => s.MoveTrackFile(It.IsAny<TrackFile>(), It.IsAny<Artist>()))
|
||||||
.Throws(new SameFilenameException("Same file name", "Filename"));
|
.Throws(new SameFilenameException("Same file name", "Filename"));
|
||||||
|
|
||||||
Subject.Execute(new RenameFilesCommand(_series.Id, new List<int> { 1 }));
|
Subject.Execute(new RenameFilesCommand(_artist.Id, new List<int> { 1 }));
|
||||||
|
|
||||||
Mocker.GetMock<IEventAggregator>()
|
Mocker.GetMock<IEventAggregator>()
|
||||||
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Never());
|
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Never());
|
||||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
GivenEpisodeFiles();
|
GivenEpisodeFiles();
|
||||||
GivenMovedFiles();
|
GivenMovedFiles();
|
||||||
|
|
||||||
Subject.Execute(new RenameFilesCommand(_series.Id, new List<int> { 1 }));
|
Subject.Execute(new RenameFilesCommand(_artist.Id, new List<int> { 1 }));
|
||||||
|
|
||||||
Mocker.GetMock<IEventAggregator>()
|
Mocker.GetMock<IEventAggregator>()
|
||||||
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Once());
|
.Verify(v => v.PublishEvent(It.IsAny<SeriesRenamedEvent>()), Times.Once());
|
||||||
|
@ -99,10 +99,10 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
GivenEpisodeFiles();
|
GivenEpisodeFiles();
|
||||||
GivenMovedFiles();
|
GivenMovedFiles();
|
||||||
|
|
||||||
Subject.Execute(new RenameFilesCommand(_series.Id, new List<int> { 1 }));
|
Subject.Execute(new RenameFilesCommand(_artist.Id, new List<int> { 1 }));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Update(It.IsAny<EpisodeFile>()), Times.Exactly(2));
|
.Verify(v => v.Update(It.IsAny<TrackFile>()), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
|
|
||||||
var files = new List<int> { 1 };
|
var files = new List<int> { 1 };
|
||||||
|
|
||||||
Subject.Execute(new RenameFilesCommand(_series.Id, files));
|
Subject.Execute(new RenameFilesCommand(_artist.Id, files));
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>()
|
Mocker.GetMock<IMediaFileService>()
|
||||||
.Verify(v => v.Get(files), Times.Once());
|
.Verify(v => v.Get(files), Times.Once());
|
||||||
|
|
|
@ -9,25 +9,26 @@ using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.MediaFiles
|
namespace NzbDrone.Core.Test.MediaFiles
|
||||||
{
|
{
|
||||||
public class UpgradeMediaFileServiceFixture : CoreTest<UpgradeMediaFileService>
|
public class UpgradeMediaFileServiceFixture : CoreTest<UpgradeMediaFileService>
|
||||||
{
|
{
|
||||||
private EpisodeFile _episodeFile;
|
private TrackFile _trackFile;
|
||||||
private LocalEpisode _localEpisode;
|
private LocalTrack _localTrack;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
_localEpisode = new LocalEpisode();
|
_localTrack = new LocalTrack();
|
||||||
_localEpisode.Series = new Series
|
_localTrack.Artist = new Artist
|
||||||
{
|
{
|
||||||
Path = @"C:\Test\TV\Series".AsOsAgnostic()
|
Path = @"C:\Test\Music\Artist".AsOsAgnostic()
|
||||||
};
|
};
|
||||||
|
|
||||||
_episodeFile = Builder<EpisodeFile>
|
_trackFile = Builder<TrackFile>
|
||||||
.CreateNew()
|
.CreateNew()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -37,13 +38,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenSingleEpisodeWithSingleEpisodeFile()
|
private void GivenSingleTrackWithSingleTrackFile()
|
||||||
{
|
{
|
||||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(1)
|
||||||
.All()
|
.All()
|
||||||
.With(e => e.EpisodeFileId = 1)
|
.With(e => e.TrackFileId = 1)
|
||||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
||||||
new EpisodeFile
|
new TrackFile
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||||
|
@ -52,13 +53,13 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenMultipleEpisodesWithSingleEpisodeFile()
|
private void GivenMultipleTracksWithSingleTrackFile()
|
||||||
{
|
{
|
||||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
||||||
.All()
|
.All()
|
||||||
.With(e => e.EpisodeFileId = 1)
|
.With(e => e.TrackFileId = 1)
|
||||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
||||||
new EpisodeFile
|
new TrackFile
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||||
|
@ -67,19 +68,19 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenMultipleEpisodesWithMultipleEpisodeFiles()
|
private void GivenMultipleTracksWithMultipleTrackFiles()
|
||||||
{
|
{
|
||||||
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(2)
|
_localTrack.Tracks = Builder<Track>.CreateListOfSize(2)
|
||||||
.TheFirst(1)
|
.TheFirst(1)
|
||||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
||||||
new EpisodeFile
|
new TrackFile
|
||||||
{
|
{
|
||||||
Id = 1,
|
Id = 1,
|
||||||
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
RelativePath = @"Season 01\30.rock.s01e01.avi",
|
||||||
}))
|
}))
|
||||||
.TheNext(1)
|
.TheNext(1)
|
||||||
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
.With(e => e.TrackFile = new LazyLoaded<TrackFile>(
|
||||||
new EpisodeFile
|
new TrackFile
|
||||||
{
|
{
|
||||||
Id = 2,
|
Id = 2,
|
||||||
RelativePath = @"Season 01\30.rock.s01e02.avi",
|
RelativePath = @"Season 01\30.rock.s01e02.avi",
|
||||||
|
@ -89,11 +90,11 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_single_episode_file_once()
|
public void should_delete_single_track_file_once()
|
||||||
{
|
{
|
||||||
GivenSingleEpisodeWithSingleEpisodeFile();
|
GivenSingleTrackWithSingleTrackFile();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -101,9 +102,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_the_same_episode_file_only_once()
|
public void should_delete_the_same_episode_file_only_once()
|
||||||
{
|
{
|
||||||
GivenMultipleEpisodesWithSingleEpisodeFile();
|
GivenMultipleTracksWithSingleTrackFile();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Once());
|
||||||
}
|
}
|
||||||
|
@ -111,9 +112,9 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_multiple_different_episode_files()
|
public void should_delete_multiple_different_episode_files()
|
||||||
{
|
{
|
||||||
GivenMultipleEpisodesWithMultipleEpisodeFiles();
|
GivenMultipleTracksWithMultipleTrackFiles();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
|
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(2));
|
||||||
}
|
}
|
||||||
|
@ -121,37 +122,37 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_episode_file_from_database()
|
public void should_delete_episode_file_from_database()
|
||||||
{
|
{
|
||||||
GivenSingleEpisodeWithSingleEpisodeFile();
|
GivenSingleTrackWithSingleTrackFile();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(It.IsAny<EpisodeFile>(), DeleteMediaFileReason.Upgrade), Times.Once());
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(It.IsAny<TrackFile>(), DeleteMediaFileReason.Upgrade), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_delete_existing_file_fromdb_if_file_doesnt_exist()
|
public void should_delete_existing_file_fromdb_if_file_doesnt_exist()
|
||||||
{
|
{
|
||||||
GivenSingleEpisodeWithSingleEpisodeFile();
|
GivenSingleTrackWithSingleTrackFile();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.FileExists(It.IsAny<string>()))
|
.Setup(c => c.FileExists(It.IsAny<string>()))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Once());
|
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localTrack.Tracks.Single().TrackFile.Value, DeleteMediaFileReason.Upgrade), Times.Once());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_try_to_recyclebin_existing_file_if_file_doesnt_exist()
|
public void should_not_try_to_recyclebin_existing_file_if_file_doesnt_exist()
|
||||||
{
|
{
|
||||||
GivenSingleEpisodeWithSingleEpisodeFile();
|
GivenSingleTrackWithSingleTrackFile();
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.FileExists(It.IsAny<string>()))
|
.Setup(c => c.FileExists(It.IsAny<string>()))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack);
|
||||||
|
|
||||||
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
Mocker.GetMock<IRecycleBinProvider>().Verify(v => v.DeleteFile(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
|
||||||
}
|
}
|
||||||
|
@ -159,17 +160,17 @@ namespace NzbDrone.Core.Test.MediaFiles
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_old_episode_file_in_oldFiles()
|
public void should_return_old_episode_file_in_oldFiles()
|
||||||
{
|
{
|
||||||
GivenSingleEpisodeWithSingleEpisodeFile();
|
GivenSingleTrackWithSingleTrackFile();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(1);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack).OldFiles.Count.Should().Be(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_old_episode_files_in_oldFiles()
|
public void should_return_old_episode_files_in_oldFiles()
|
||||||
{
|
{
|
||||||
GivenMultipleEpisodesWithMultipleEpisodeFiles();
|
GivenMultipleTracksWithMultipleTrackFiles();
|
||||||
|
|
||||||
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(2);
|
Subject.UpgradeTrackFile(_trackFile, _localTrack).OldFiles.Count.Should().Be(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,9 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
||||||
new QualitiesBelowCutoff(profile.Id, new[] {Quality.MP3192.Id})
|
new QualitiesBelowCutoff(profile.Id, new[] {Quality.MP3192.Id})
|
||||||
};
|
};
|
||||||
|
|
||||||
var qualityMet = new EpisodeFile { RelativePath = "a", Quality = new QualityModel { Quality = Quality.MP3256 } };
|
var qualityMet = new TrackFile { RelativePath = "a", Quality = new QualityModel { Quality = Quality.MP3256 } };
|
||||||
var qualityUnmet = new EpisodeFile { RelativePath = "b", Quality = new QualityModel { Quality = Quality.MP3192 } };
|
var qualityUnmet = new TrackFile { RelativePath = "b", Quality = new QualityModel { Quality = Quality.MP3192 } };
|
||||||
var qualityRawHD = new EpisodeFile { RelativePath = "c", Quality = new QualityModel { Quality = Quality.FLAC } };
|
var qualityRawHD = new TrackFile { RelativePath = "c", Quality = new QualityModel { Quality = Quality.FLAC } };
|
||||||
|
|
||||||
MediaFileRepository fileRepository = Mocker.Resolve<MediaFileRepository>();
|
MediaFileRepository fileRepository = Mocker.Resolve<MediaFileRepository>();
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Marr.Data.QGen;
|
using Marr.Data.QGen;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Datastore.Extensions;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Core.Music
|
||||||
List<Album> GetAlbums(int artistId);
|
List<Album> GetAlbums(int artistId);
|
||||||
Album FindByName(string cleanTitle);
|
Album FindByName(string cleanTitle);
|
||||||
Album FindById(string spotifyId);
|
Album FindById(string spotifyId);
|
||||||
|
PagingSpec<Album> AlbumsWithoutFiles(PagingSpec<Album> pagingSpec);
|
||||||
List<Album> AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored);
|
List<Album> AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored);
|
||||||
void SetMonitoredFlat(Album album, bool monitored);
|
void SetMonitoredFlat(Album album, bool monitored);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,16 @@ namespace NzbDrone.Core.Music
|
||||||
return Query.Where(s => s.ForeignAlbumId == foreignAlbumId).SingleOrDefault();
|
return Query.Where(s => s.ForeignAlbumId == foreignAlbumId).SingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PagingSpec<Album> AlbumsWithoutFiles(PagingSpec<Album> pagingSpec)
|
||||||
|
{
|
||||||
|
var currentTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
pagingSpec.TotalRecords = GetMissingAlbumsQuery(pagingSpec, currentTime).GetRowCount();
|
||||||
|
pagingSpec.Records = GetMissingAlbumsQuery(pagingSpec, currentTime).ToList();
|
||||||
|
|
||||||
|
return pagingSpec;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Album> AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored)
|
public List<Album> AlbumsBetweenDates(DateTime startDate, DateTime endDate, bool includeUnmonitored)
|
||||||
{
|
{
|
||||||
var query = Query.Join<Album, Artist>(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id)
|
var query = Query.Join<Album, Artist>(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id)
|
||||||
|
@ -55,6 +67,24 @@ namespace NzbDrone.Core.Music
|
||||||
return query.ToList();
|
return query.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SortBuilder<Album> GetMissingAlbumsQuery(PagingSpec<Album> pagingSpec, DateTime currentTime)
|
||||||
|
{
|
||||||
|
return Query.Join<Album, Artist>(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id)
|
||||||
|
.Where<Album>(pagingSpec.FilterExpression)
|
||||||
|
|
||||||
|
.AndWhere(BuildReleaseDateCutoffWhereClause(currentTime))
|
||||||
|
//.Where<Track>(t => t.TrackFileId == 0)
|
||||||
|
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||||
|
.Skip(pagingSpec.PagingOffset())
|
||||||
|
.Take(pagingSpec.PageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BuildReleaseDateCutoffWhereClause(DateTime currentTime)
|
||||||
|
{
|
||||||
|
return string.Format("WHERE datetime(strftime('%s', [t0].[ReleaseDate]), 'unixepoch') <= '{0}'",
|
||||||
|
currentTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
|
|
||||||
public void SetMonitoredFlat(Album album, bool monitored)
|
public void SetMonitoredFlat(Album album, bool monitored)
|
||||||
{
|
{
|
||||||
album.Monitored = monitored;
|
album.Monitored = monitored;
|
||||||
|
|
|
@ -5,6 +5,7 @@ using NzbDrone.Core.Organizer;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -25,6 +26,7 @@ namespace NzbDrone.Core.Music
|
||||||
Album UpdateAlbum(Album album);
|
Album UpdateAlbum(Album album);
|
||||||
List<Album> UpdateAlbums(List<Album> album);
|
List<Album> UpdateAlbums(List<Album> album);
|
||||||
void SetAlbumMonitored(int albumId, bool monitored);
|
void SetAlbumMonitored(int albumId, bool monitored);
|
||||||
|
PagingSpec<Album> AlbumsWithoutFiles(PagingSpec<Album> pagingSpec);
|
||||||
List<Album> AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored);
|
List<Album> AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored);
|
||||||
void InsertMany(List<Album> albums);
|
void InsertMany(List<Album> albums);
|
||||||
void UpdateMany(List<Album> albums);
|
void UpdateMany(List<Album> albums);
|
||||||
|
@ -111,6 +113,13 @@ namespace NzbDrone.Core.Music
|
||||||
_albumRepository.SetFields(album, s => s.AddOptions);
|
_albumRepository.SetFields(album, s => s.AddOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PagingSpec<Album> AlbumsWithoutFiles(PagingSpec<Album> pagingSpec)
|
||||||
|
{
|
||||||
|
var albumResult = _albumRepository.AlbumsWithoutFiles(pagingSpec);
|
||||||
|
|
||||||
|
return albumResult;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Album> AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored)
|
public List<Album> AlbumsBetweenDates(DateTime start, DateTime end, bool includeUnmonitored)
|
||||||
{
|
{
|
||||||
var albums = _albumRepository.AlbumsBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored);
|
var albums = _albumRepository.AlbumsBetweenDates(start.ToUniversalTime(), end.ToUniversalTime(), includeUnmonitored);
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ArtistEditorFixture : IntegrationTest
|
||||||
|
{
|
||||||
|
private void GivenExistingArtist()
|
||||||
|
{
|
||||||
|
foreach (var name in new[] { "90210", "Dexter" })
|
||||||
|
{
|
||||||
|
var newArtist = Artist.Lookup(name).First();
|
||||||
|
|
||||||
|
newArtist.ProfileId = 1;
|
||||||
|
newArtist.Path = string.Format(@"C:\Test\{0}", name).AsOsAgnostic();
|
||||||
|
|
||||||
|
Artist.Post(newArtist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_update_multiple_artist()
|
||||||
|
{
|
||||||
|
GivenExistingArtist();
|
||||||
|
|
||||||
|
var artist = Artist.All();
|
||||||
|
|
||||||
|
foreach (var s in artist)
|
||||||
|
{
|
||||||
|
s.ProfileId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = Artist.Editor(artist);
|
||||||
|
|
||||||
|
result.Should().HaveCount(2);
|
||||||
|
result.TrueForAll(s => s.ProfileId == 2).Should().BeTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
173
src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs
Normal file
173
src/NzbDrone.Integration.Test/ApiTests/ArtistFixture.cs
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ArtistFixture : IntegrationTest
|
||||||
|
{
|
||||||
|
[Test, Order(0)]
|
||||||
|
public void add_artist_with_tags_should_store_them()
|
||||||
|
{
|
||||||
|
EnsureNoArtsit("266189", "Alien Ant Farm");
|
||||||
|
var tag = EnsureTag("abc");
|
||||||
|
|
||||||
|
var artist = Artist.Lookup("266189").Single();
|
||||||
|
|
||||||
|
artist.ProfileId = 1;
|
||||||
|
artist.Path = Path.Combine(ArtistRootFolder, artist.Name);
|
||||||
|
artist.Tags = new HashSet<int>();
|
||||||
|
artist.Tags.Add(tag.Id);
|
||||||
|
|
||||||
|
var result = Artist.Post(artist);
|
||||||
|
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result.Tags.Should().Equal(tag.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(0)]
|
||||||
|
public void add_artist_without_profileid_should_return_badrequest()
|
||||||
|
{
|
||||||
|
EnsureNoArtsit("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
var artist = Artist.Lookup("tvdb:266189").Single();
|
||||||
|
|
||||||
|
artist.Path = Path.Combine(ArtistRootFolder, artist.Name);
|
||||||
|
|
||||||
|
Artist.InvalidPost(artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(0)]
|
||||||
|
public void add_artist_without_path_should_return_badrequest()
|
||||||
|
{
|
||||||
|
EnsureNoArtsit("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
var artist = Artist.Lookup("tvdb:266189").Single();
|
||||||
|
|
||||||
|
artist.ProfileId = 1;
|
||||||
|
|
||||||
|
Artist.InvalidPost(artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(1)]
|
||||||
|
public void add_artist()
|
||||||
|
{
|
||||||
|
EnsureNoArtsit("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
var artist = Artist.Lookup("tvdb:266189").Single();
|
||||||
|
|
||||||
|
artist.ProfileId = 1;
|
||||||
|
artist.Path = Path.Combine(ArtistRootFolder, artist.Name);
|
||||||
|
|
||||||
|
var result = Artist.Post(artist);
|
||||||
|
|
||||||
|
result.Should().NotBeNull();
|
||||||
|
result.Id.Should().NotBe(0);
|
||||||
|
result.ProfileId.Should().Be(1);
|
||||||
|
result.Path.Should().Be(Path.Combine(ArtistRootFolder, artist.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test, Order(2)]
|
||||||
|
public void get_all_artist()
|
||||||
|
{
|
||||||
|
EnsureArtist("266189", "Alien Ant Farm");
|
||||||
|
EnsureArtist("73065", "Coldplay");
|
||||||
|
|
||||||
|
Artist.All().Should().NotBeNullOrEmpty();
|
||||||
|
Artist.All().Should().Contain(v => v.ForeignArtistId == "73065");
|
||||||
|
Artist.All().Should().Contain(v => v.ForeignArtistId == "266189");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(2)]
|
||||||
|
public void get_artist_by_id()
|
||||||
|
{
|
||||||
|
var artist = EnsureArtist("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
var result = Artist.Get(artist.Id);
|
||||||
|
|
||||||
|
result.ForeignArtistId.Should().Be("266189");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void get_artist_by_unknown_id_should_return_404()
|
||||||
|
{
|
||||||
|
var result = Artist.InvalidGet(1000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(2)]
|
||||||
|
public void update_artist_profile_id()
|
||||||
|
{
|
||||||
|
var artist = EnsureArtist("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
var profileId = 1;
|
||||||
|
if (artist.ProfileId == profileId)
|
||||||
|
{
|
||||||
|
profileId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
artist.ProfileId = profileId;
|
||||||
|
|
||||||
|
var result = Artist.Put(artist);
|
||||||
|
|
||||||
|
Artist.Get(artist.Id).ProfileId.Should().Be(profileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(3)]
|
||||||
|
public void update_artist_monitored()
|
||||||
|
{
|
||||||
|
var artist = EnsureArtist("266189", "Alien Ant Farm", false);
|
||||||
|
|
||||||
|
artist.Monitored.Should().BeFalse();
|
||||||
|
//artist.Seasons.First().Monitored.Should().BeFalse();
|
||||||
|
|
||||||
|
artist.Monitored = true;
|
||||||
|
//artist.Seasons.ForEach(season =>
|
||||||
|
//{
|
||||||
|
// season.Monitored = true;
|
||||||
|
//});
|
||||||
|
|
||||||
|
var result = Artist.Put(artist);
|
||||||
|
|
||||||
|
result.Monitored.Should().BeTrue();
|
||||||
|
//result.Seasons.First().Monitored.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(3)]
|
||||||
|
public void update_artist_tags()
|
||||||
|
{
|
||||||
|
var artist = EnsureArtist("266189", "Alien Ant Farm");
|
||||||
|
var tag = EnsureTag("abc");
|
||||||
|
|
||||||
|
if (artist.Tags.Contains(tag.Id))
|
||||||
|
{
|
||||||
|
artist.Tags.Remove(tag.Id);
|
||||||
|
|
||||||
|
var result = Artist.Put(artist);
|
||||||
|
Artist.Get(artist.Id).Tags.Should().NotContain(tag.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
artist.Tags.Add(tag.Id);
|
||||||
|
|
||||||
|
var result = Artist.Put(artist);
|
||||||
|
Artist.Get(artist.Id).Tags.Should().Contain(tag.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, Order(4)]
|
||||||
|
public void delete_artist()
|
||||||
|
{
|
||||||
|
var artist = EnsureArtist("266189", "Alien Ant Farm");
|
||||||
|
|
||||||
|
Artist.Get(artist.Id).Should().NotBeNull();
|
||||||
|
|
||||||
|
Artist.Delete(artist.Id);
|
||||||
|
|
||||||
|
Artist.All().Should().NotContain(v => v.ForeignArtistId == "266189");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class ArtistLookupFixture : IntegrationTest
|
||||||
|
{
|
||||||
|
[TestCase("archer", "Archer (2009)")]
|
||||||
|
[TestCase("90210", "90210")]
|
||||||
|
public void lookup_new_artist_by_name(string term, string name)
|
||||||
|
{
|
||||||
|
var artist = Artist.Lookup(term);
|
||||||
|
|
||||||
|
artist.Should().NotBeEmpty();
|
||||||
|
artist.Should().Contain(c => c.Name == name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void lookup_new_series_by_tvdbid()
|
||||||
|
{
|
||||||
|
var artist = Artist.Lookup("tvdb:266189");
|
||||||
|
|
||||||
|
artist.Should().NotBeEmpty();
|
||||||
|
artist.Should().Contain(c => c.Name == "The Blacklist");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[Ignore("Unreliable")]
|
||||||
|
public void lookup_random_series_using_asterix()
|
||||||
|
{
|
||||||
|
var artist = Artist.Lookup("*");
|
||||||
|
|
||||||
|
artist.Should().NotBeEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +1,23 @@
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class BlacklistFixture : IntegrationTest
|
public class BlacklistFixture : IntegrationTest
|
||||||
{
|
{
|
||||||
private SeriesResource _series;
|
private ArtistResource _artist;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore("Adding to blacklist not supported")]
|
[Ignore("Adding to blacklist not supported")]
|
||||||
public void should_be_able_to_add_to_blacklist()
|
public void should_be_able_to_add_to_blacklist()
|
||||||
{
|
{
|
||||||
_series = EnsureSeries(266189, "The Blacklist");
|
_artist = EnsureArtist("266189", "The Blacklist");
|
||||||
|
|
||||||
Blacklist.Post(new Api.Blacklist.BlacklistResource
|
Blacklist.Post(new Api.Blacklist.BlacklistResource
|
||||||
{
|
{
|
||||||
SeriesId = _series.Id,
|
SeriesId = _artist.Id,
|
||||||
SourceTitle = "Blacklist.S01E01.Brought.To.You.By-BoomBoxHD"
|
SourceTitle = "Blacklist.S01E01.Brought.To.You.By-BoomBoxHD"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Api.Episodes;
|
using NzbDrone.Api.Albums;
|
||||||
using NzbDrone.Integration.Test.Client;
|
using NzbDrone.Integration.Test.Client;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -11,43 +11,43 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CalendarFixture : IntegrationTest
|
public class CalendarFixture : IntegrationTest
|
||||||
{
|
{
|
||||||
public ClientBase<EpisodeResource> Calendar;
|
public ClientBase<AlbumResource> Calendar;
|
||||||
|
|
||||||
protected override void InitRestClients()
|
protected override void InitRestClients()
|
||||||
{
|
{
|
||||||
base.InitRestClients();
|
base.InitRestClients();
|
||||||
|
|
||||||
Calendar = new ClientBase<EpisodeResource>(RestClient, ApiKey, "calendar");
|
Calendar = new ClientBase<AlbumResource>(RestClient, ApiKey, "calendar");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_get_episodes()
|
public void should_be_able_to_get_albums()
|
||||||
{
|
{
|
||||||
var series = EnsureSeries(266189, "The Blacklist", true);
|
var artist = EnsureArtist("aaaa_aaaaa_asaaaaa", "Alien Ant Farm", true);
|
||||||
|
|
||||||
var request = Calendar.BuildRequest();
|
var request = Calendar.BuildRequest();
|
||||||
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
||||||
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
||||||
var items = Calendar.Get<List<EpisodeResource>>(request);
|
var items = Calendar.Get<List<AlbumResource>>(request);
|
||||||
|
|
||||||
items = items.Where(v => v.SeriesId == series.Id).ToList();
|
items = items.Where(v => v.ArtistId == artist.Id).ToList();
|
||||||
|
|
||||||
items.Should().HaveCount(1);
|
items.Should().HaveCount(1);
|
||||||
items.First().Title.Should().Be("The Troll Farmer");
|
items.First().Title.Should().Be("The Troll Farmer");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_be_able_to_get_unmonitored_episodes()
|
public void should_not_be_able_to_get_unmonitored_albums()
|
||||||
{
|
{
|
||||||
var series = EnsureSeries(266189, "The Blacklist", false);
|
var artist = EnsureArtist("aaaa_aaaaa_asaaaaa", "Alien Ant Farm", false);
|
||||||
|
|
||||||
var request = Calendar.BuildRequest();
|
var request = Calendar.BuildRequest();
|
||||||
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
||||||
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
||||||
request.AddParameter("unmonitored", "false");
|
request.AddParameter("unmonitored", "false");
|
||||||
var items = Calendar.Get<List<EpisodeResource>>(request);
|
var items = Calendar.Get<List<AlbumResource>>(request);
|
||||||
|
|
||||||
items = items.Where(v => v.SeriesId == series.Id).ToList();
|
items = items.Where(v => v.ArtistId == artist.Id).ToList();
|
||||||
|
|
||||||
items.Should().BeEmpty();
|
items.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,15 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_get_unmonitored_episodes()
|
public void should_be_able_to_get_unmonitored_episodes()
|
||||||
{
|
{
|
||||||
var series = EnsureSeries(266189, "The Blacklist", false);
|
var artist = EnsureArtist("aaaa_aaaaa_asaaaaa", "Alien Ant Farm", false);
|
||||||
|
|
||||||
var request = Calendar.BuildRequest();
|
var request = Calendar.BuildRequest();
|
||||||
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
request.AddParameter("start", new DateTime(2015, 10, 1).ToString("s") + "Z");
|
||||||
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
request.AddParameter("end", new DateTime(2015, 10, 3).ToString("s") + "Z");
|
||||||
request.AddParameter("unmonitored", "true");
|
request.AddParameter("unmonitored", "true");
|
||||||
var items = Calendar.Get<List<EpisodeResource>>(request);
|
var items = Calendar.Get<List<AlbumResource>>(request);
|
||||||
|
|
||||||
items = items.Where(v => v.SeriesId == series.Id).ToList();
|
items = items.Where(v => v.ArtistId == artist.Id).ToList();
|
||||||
|
|
||||||
items.Should().HaveCount(1);
|
items.Should().HaveCount(1);
|
||||||
items.First().Title.Should().Be("The Troll Farmer");
|
items.First().Title.Should().Be("The Troll Farmer");
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
using System.Threading;
|
|
||||||
using FluentAssertions;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using NzbDrone.Api.Series;
|
|
||||||
using System.Linq;
|
|
||||||
using NzbDrone.Test.Common;
|
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class EpisodeFixture : IntegrationTest
|
|
||||||
{
|
|
||||||
private SeriesResource series;
|
|
||||||
|
|
||||||
[SetUp]
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
series = GivenSeriesWithEpisodes();
|
|
||||||
}
|
|
||||||
|
|
||||||
private SeriesResource GivenSeriesWithEpisodes()
|
|
||||||
{
|
|
||||||
var newSeries = Series.Lookup("archer").Single(c => c.TvdbId == 110381);
|
|
||||||
|
|
||||||
newSeries.ProfileId = 1;
|
|
||||||
newSeries.Path = @"C:\Test\Archer".AsOsAgnostic();
|
|
||||||
|
|
||||||
newSeries = Series.Post(newSeries);
|
|
||||||
|
|
||||||
WaitForCompletion(() => Episodes.GetEpisodesInSeries(newSeries.Id).Count > 0);
|
|
||||||
|
|
||||||
return newSeries;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_be_able_to_get_all_episodes_in_series()
|
|
||||||
{
|
|
||||||
Episodes.GetEpisodesInSeries(series.Id).Count.Should().BeGreaterThan(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_be_able_to_get_a_single_episode()
|
|
||||||
{
|
|
||||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
|
||||||
|
|
||||||
Episodes.Get(episodes.First().Id).Should().NotBeNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_be_able_to_set_monitor_status()
|
|
||||||
{
|
|
||||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
|
||||||
var updatedEpisode = episodes.First();
|
|
||||||
updatedEpisode.Monitored = false;
|
|
||||||
|
|
||||||
Episodes.Put(updatedEpisode).Monitored.Should().BeFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[TearDown]
|
|
||||||
public void TearDown()
|
|
||||||
{
|
|
||||||
Series.Delete(series.Id);
|
|
||||||
Thread.Sleep(2000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
using FluentAssertions;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using System.Linq;
|
|
||||||
using NzbDrone.Test.Common;
|
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class SeriesEditorFixture : IntegrationTest
|
|
||||||
{
|
|
||||||
private void GivenExistingSeries()
|
|
||||||
{
|
|
||||||
foreach (var title in new[] { "90210", "Dexter" })
|
|
||||||
{
|
|
||||||
var newSeries = Series.Lookup(title).First();
|
|
||||||
|
|
||||||
newSeries.ProfileId = 1;
|
|
||||||
newSeries.Path = string.Format(@"C:\Test\{0}", title).AsOsAgnostic();
|
|
||||||
|
|
||||||
Series.Post(newSeries);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void should_be_able_to_update_multiple_series()
|
|
||||||
{
|
|
||||||
GivenExistingSeries();
|
|
||||||
|
|
||||||
var series = Series.All();
|
|
||||||
|
|
||||||
foreach (var s in series)
|
|
||||||
{
|
|
||||||
s.ProfileId = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Series.Editor(series);
|
|
||||||
|
|
||||||
result.Should().HaveCount(2);
|
|
||||||
result.TrueForAll(s => s.ProfileId == 2).Should().BeTrue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,173 +0,0 @@
|
||||||
using FluentAssertions;
|
|
||||||
using NUnit.Framework;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class SeriesFixture : IntegrationTest
|
|
||||||
{
|
|
||||||
[Test, Order(0)]
|
|
||||||
public void add_series_with_tags_should_store_them()
|
|
||||||
{
|
|
||||||
EnsureNoSeries(266189, "The Blacklist");
|
|
||||||
var tag = EnsureTag("abc");
|
|
||||||
|
|
||||||
var series = Series.Lookup("tvdb:266189").Single();
|
|
||||||
|
|
||||||
series.ProfileId = 1;
|
|
||||||
series.Path = Path.Combine(SeriesRootFolder, series.Title);
|
|
||||||
series.Tags = new HashSet<int>();
|
|
||||||
series.Tags.Add(tag.Id);
|
|
||||||
|
|
||||||
var result = Series.Post(series);
|
|
||||||
|
|
||||||
result.Should().NotBeNull();
|
|
||||||
result.Tags.Should().Equal(tag.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(0)]
|
|
||||||
public void add_series_without_profileid_should_return_badrequest()
|
|
||||||
{
|
|
||||||
EnsureNoSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
var series = Series.Lookup("tvdb:266189").Single();
|
|
||||||
|
|
||||||
series.Path = Path.Combine(SeriesRootFolder, series.Title);
|
|
||||||
|
|
||||||
Series.InvalidPost(series);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(0)]
|
|
||||||
public void add_series_without_path_should_return_badrequest()
|
|
||||||
{
|
|
||||||
EnsureNoSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
var series = Series.Lookup("tvdb:266189").Single();
|
|
||||||
|
|
||||||
series.ProfileId = 1;
|
|
||||||
|
|
||||||
Series.InvalidPost(series);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(1)]
|
|
||||||
public void add_series()
|
|
||||||
{
|
|
||||||
EnsureNoSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
var series = Series.Lookup("tvdb:266189").Single();
|
|
||||||
|
|
||||||
series.ProfileId = 1;
|
|
||||||
series.Path = Path.Combine(SeriesRootFolder, series.Title);
|
|
||||||
|
|
||||||
var result = Series.Post(series);
|
|
||||||
|
|
||||||
result.Should().NotBeNull();
|
|
||||||
result.Id.Should().NotBe(0);
|
|
||||||
result.ProfileId.Should().Be(1);
|
|
||||||
result.Path.Should().Be(Path.Combine(SeriesRootFolder, series.Title));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Test, Order(2)]
|
|
||||||
public void get_all_series()
|
|
||||||
{
|
|
||||||
EnsureSeries(266189, "The Blacklist");
|
|
||||||
EnsureSeries(73065, "Archer");
|
|
||||||
|
|
||||||
Series.All().Should().NotBeNullOrEmpty();
|
|
||||||
Series.All().Should().Contain(v => v.TvdbId == 73065);
|
|
||||||
Series.All().Should().Contain(v => v.TvdbId == 266189);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(2)]
|
|
||||||
public void get_series_by_id()
|
|
||||||
{
|
|
||||||
var series = EnsureSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
var result = Series.Get(series.Id);
|
|
||||||
|
|
||||||
result.TvdbId.Should().Be(266189);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void get_series_by_unknown_id_should_return_404()
|
|
||||||
{
|
|
||||||
var result = Series.InvalidGet(1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(2)]
|
|
||||||
public void update_series_profile_id()
|
|
||||||
{
|
|
||||||
var series = EnsureSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
var profileId = 1;
|
|
||||||
if (series.ProfileId == profileId)
|
|
||||||
{
|
|
||||||
profileId = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
series.ProfileId = profileId;
|
|
||||||
|
|
||||||
var result = Series.Put(series);
|
|
||||||
|
|
||||||
Series.Get(series.Id).ProfileId.Should().Be(profileId);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(3)]
|
|
||||||
public void update_series_monitored()
|
|
||||||
{
|
|
||||||
var series = EnsureSeries(266189, "The Blacklist", false);
|
|
||||||
|
|
||||||
series.Monitored.Should().BeFalse();
|
|
||||||
series.Seasons.First().Monitored.Should().BeFalse();
|
|
||||||
|
|
||||||
series.Monitored = true;
|
|
||||||
series.Seasons.ForEach(season =>
|
|
||||||
{
|
|
||||||
season.Monitored = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
var result = Series.Put(series);
|
|
||||||
|
|
||||||
result.Monitored.Should().BeTrue();
|
|
||||||
result.Seasons.First().Monitored.Should().BeTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(3)]
|
|
||||||
public void update_series_tags()
|
|
||||||
{
|
|
||||||
var series = EnsureSeries(266189, "The Blacklist");
|
|
||||||
var tag = EnsureTag("abc");
|
|
||||||
|
|
||||||
if (series.Tags.Contains(tag.Id))
|
|
||||||
{
|
|
||||||
series.Tags.Remove(tag.Id);
|
|
||||||
|
|
||||||
var result = Series.Put(series);
|
|
||||||
Series.Get(series.Id).Tags.Should().NotContain(tag.Id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
series.Tags.Add(tag.Id);
|
|
||||||
|
|
||||||
var result = Series.Put(series);
|
|
||||||
Series.Get(series.Id).Tags.Should().Contain(tag.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test, Order(4)]
|
|
||||||
public void delete_series()
|
|
||||||
{
|
|
||||||
var series = EnsureSeries(266189, "The Blacklist");
|
|
||||||
|
|
||||||
Series.Get(series.Id).Should().NotBeNull();
|
|
||||||
|
|
||||||
Series.Delete(series.Id);
|
|
||||||
|
|
||||||
Series.All().Should().NotContain(v => v.TvdbId == 266189);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
using FluentAssertions;
|
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class SeriesLookupFixture : IntegrationTest
|
|
||||||
{
|
|
||||||
[TestCase("archer", "Archer (2009)")]
|
|
||||||
[TestCase("90210", "90210")]
|
|
||||||
public void lookup_new_series_by_title(string term, string title)
|
|
||||||
{
|
|
||||||
var series = Series.Lookup(term);
|
|
||||||
|
|
||||||
series.Should().NotBeEmpty();
|
|
||||||
series.Should().Contain(c => c.Title == title);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void lookup_new_series_by_tvdbid()
|
|
||||||
{
|
|
||||||
var series = Series.Lookup("tvdb:266189");
|
|
||||||
|
|
||||||
series.Should().NotBeEmpty();
|
|
||||||
series.Should().Contain(c => c.Title == "The Blacklist");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
[Ignore("Unreliable")]
|
|
||||||
public void lookup_random_series_using_asterix()
|
|
||||||
{
|
|
||||||
var series = Series.Lookup("*");
|
|
||||||
|
|
||||||
series.Should().NotBeEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,10 +3,10 @@
|
||||||
namespace NzbDrone.Integration.Test.ApiTests
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
{
|
{
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class EpisodeFileFixture : IntegrationTest
|
public class TrackFileFixture : IntegrationTest
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void get_all_episodefiles()
|
public void get_all_trackfiles()
|
||||||
{
|
{
|
||||||
Assert.Ignore("TODO");
|
Assert.Ignore("TODO");
|
||||||
}
|
}
|
68
src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs
Normal file
68
src/NzbDrone.Integration.Test/ApiTests/TrackFixture.cs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
using System.Threading;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Api.Series;
|
||||||
|
using NzbDrone.Api.Music;
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.ApiTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TrackFixture : IntegrationTest
|
||||||
|
{
|
||||||
|
private ArtistResource artist;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
artist = GivenArtistWithTracks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArtistResource GivenArtistWithTracks()
|
||||||
|
{
|
||||||
|
var newArtist = Artist.Lookup("archer").Single(c => c.ForeignArtistId == "110381");
|
||||||
|
|
||||||
|
newArtist.ProfileId = 1;
|
||||||
|
newArtist.Path = @"C:\Test\Archer".AsOsAgnostic();
|
||||||
|
|
||||||
|
newArtist = Artist.Post(newArtist);
|
||||||
|
|
||||||
|
WaitForCompletion(() => Tracks.GetTracksInArtist(newArtist.Id).Count > 0);
|
||||||
|
|
||||||
|
return newArtist;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_get_all_tracks_in_artist()
|
||||||
|
{
|
||||||
|
Tracks.GetTracksInArtist(artist.Id).Count.Should().BeGreaterThan(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_get_a_single_track()
|
||||||
|
{
|
||||||
|
var tracks = Tracks.GetTracksInArtist(artist.Id);
|
||||||
|
|
||||||
|
Tracks.Get(tracks.First().Id).Should().NotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_set_monitor_status()
|
||||||
|
{
|
||||||
|
var tracks = Tracks.GetTracksInArtist(artist.Id);
|
||||||
|
var updatedTrack = tracks.First();
|
||||||
|
updatedTrack.Monitored = false;
|
||||||
|
|
||||||
|
Tracks.Put(updatedTrack).Monitored.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
Artist.Delete(artist.Id);
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,9 +11,9 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[Test, Order(0)]
|
[Test, Order(0)]
|
||||||
public void missing_should_be_empty()
|
public void missing_should_be_empty()
|
||||||
{
|
{
|
||||||
EnsureNoSeries(266189, "The Blacklist");
|
EnsureNoArtsit("266189", "The Blacklist");
|
||||||
|
|
||||||
var result = WantedMissing.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.Should().BeEmpty();
|
result.Records.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,19 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[Test, Order(1)]
|
[Test, Order(1)]
|
||||||
public void missing_should_have_monitored_items()
|
public void missing_should_have_monitored_items()
|
||||||
{
|
{
|
||||||
EnsureSeries(266189, "The Blacklist", true);
|
EnsureArtist("266189", "The Blacklist", true);
|
||||||
|
|
||||||
var result = WantedMissing.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.Should().NotBeEmpty();
|
result.Records.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, Order(1)]
|
[Test, Order(1)]
|
||||||
public void missing_should_have_series()
|
public void missing_should_have_artist()
|
||||||
{
|
{
|
||||||
EnsureSeries(266189, "The Blacklist", true);
|
EnsureArtist("266189", "The Blacklist", true);
|
||||||
|
|
||||||
var result = WantedMissing.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.First().Series.Should().NotBeNull();
|
result.Records.First().Series.Should().NotBeNull();
|
||||||
result.Records.First().Series.Title.Should().Be("The Blacklist");
|
result.Records.First().Series.Title.Should().Be("The Blacklist");
|
||||||
|
@ -43,10 +43,10 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
public void cutoff_should_have_monitored_items()
|
public void cutoff_should_have_monitored_items()
|
||||||
{
|
{
|
||||||
EnsureProfileCutoff(1, Quality.MP3256);
|
EnsureProfileCutoff(1, Quality.MP3256);
|
||||||
var series = EnsureSeries(266189, "The Blacklist", true);
|
var artist = EnsureArtist("266189", "The Blacklist", true);
|
||||||
EnsureEpisodeFile(series, 1, 1, Quality.MP3192);
|
EnsureTrackFile(artist, 1, 1, Quality.MP3192);
|
||||||
|
|
||||||
var result = WantedCutoffUnmet.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.Should().NotBeEmpty();
|
result.Records.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[Test, Order(1)]
|
[Test, Order(1)]
|
||||||
public void missing_should_not_have_unmonitored_items()
|
public void missing_should_not_have_unmonitored_items()
|
||||||
{
|
{
|
||||||
EnsureSeries(266189, "The Blacklist", false);
|
EnsureArtist("266189", "The Blacklist", false);
|
||||||
|
|
||||||
var result = WantedMissing.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.Should().BeEmpty();
|
result.Records.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -65,22 +65,22 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
public void cutoff_should_not_have_unmonitored_items()
|
public void cutoff_should_not_have_unmonitored_items()
|
||||||
{
|
{
|
||||||
EnsureProfileCutoff(1, Quality.MP3256);
|
EnsureProfileCutoff(1, Quality.MP3256);
|
||||||
var series = EnsureSeries(266189, "The Blacklist", false);
|
var artist = EnsureArtist("266189", "The Blacklist", false);
|
||||||
EnsureEpisodeFile(series, 1, 1, Quality.MP3192);
|
EnsureTrackFile(artist, 1, 1, Quality.MP3192);
|
||||||
|
|
||||||
var result = WantedCutoffUnmet.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.Should().BeEmpty();
|
result.Records.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, Order(1)]
|
[Test, Order(1)]
|
||||||
public void cutoff_should_have_series()
|
public void cutoff_should_have_artist()
|
||||||
{
|
{
|
||||||
EnsureProfileCutoff(1, Quality.MP3256);
|
EnsureProfileCutoff(1, Quality.MP3256);
|
||||||
var series = EnsureSeries(266189, "The Blacklist", true);
|
var artist = EnsureArtist("266189", "The Blacklist", true);
|
||||||
EnsureEpisodeFile(series, 1, 1, Quality.MP3192);
|
EnsureTrackFile(artist, 1, 1, Quality.MP3192);
|
||||||
|
|
||||||
var result = WantedCutoffUnmet.GetPaged(0, 15, "airDateUtc", "desc");
|
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc");
|
||||||
|
|
||||||
result.Records.First().Series.Should().NotBeNull();
|
result.Records.First().Series.Should().NotBeNull();
|
||||||
result.Records.First().Series.Title.Should().Be("The Blacklist");
|
result.Records.First().Series.Title.Should().Be("The Blacklist");
|
||||||
|
@ -89,9 +89,9 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
[Test, Order(2)]
|
[Test, Order(2)]
|
||||||
public void missing_should_have_unmonitored_items()
|
public void missing_should_have_unmonitored_items()
|
||||||
{
|
{
|
||||||
EnsureSeries(266189, "The Blacklist", false);
|
EnsureArtist("266189", "The Blacklist", false);
|
||||||
|
|
||||||
var result = WantedMissing.GetPaged(0, 15, "airDateUtc", "desc", "monitored", "false");
|
var result = WantedMissing.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");
|
||||||
|
|
||||||
result.Records.Should().NotBeEmpty();
|
result.Records.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
@ -100,10 +100,10 @@ namespace NzbDrone.Integration.Test.ApiTests
|
||||||
public void cutoff_should_have_unmonitored_items()
|
public void cutoff_should_have_unmonitored_items()
|
||||||
{
|
{
|
||||||
EnsureProfileCutoff(1, Quality.MP3256);
|
EnsureProfileCutoff(1, Quality.MP3256);
|
||||||
var series = EnsureSeries(266189, "The Blacklist", false);
|
var artist = EnsureArtist("266189", "The Blacklist", false);
|
||||||
EnsureEpisodeFile(series, 1, 1, Quality.MP3192);
|
EnsureTrackFile(artist, 1, 1, Quality.MP3192);
|
||||||
|
|
||||||
var result = WantedCutoffUnmet.GetPaged(0, 15, "airDateUtc", "desc", "monitored", "false");
|
var result = WantedCutoffUnmet.GetPaged(0, 15, "releaseDate", "desc", "monitored", "false");
|
||||||
|
|
||||||
result.Records.Should().NotBeEmpty();
|
result.Records.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Music;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
|
||||||
namespace NzbDrone.Integration.Test.Client
|
namespace NzbDrone.Integration.Test.Client
|
||||||
{
|
{
|
||||||
public class SeriesClient : ClientBase<SeriesResource>
|
public class ArtistClient : ClientBase<ArtistResource>
|
||||||
{
|
{
|
||||||
public SeriesClient(IRestClient restClient, string apiKey)
|
public ArtistClient(IRestClient restClient, string apiKey)
|
||||||
: base(restClient, apiKey)
|
: base(restClient, apiKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SeriesResource> Lookup(string term)
|
public List<ArtistResource> Lookup(string term)
|
||||||
{
|
{
|
||||||
var request = BuildRequest("lookup?term={term}");
|
var request = BuildRequest("lookup?term={term}");
|
||||||
request.AddUrlSegment("term", term);
|
request.AddUrlSegment("term", term);
|
||||||
return Get<List<SeriesResource>>(request);
|
return Get<List<ArtistResource>>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SeriesResource> Editor(List<SeriesResource> series)
|
public List<ArtistResource> Editor(List<ArtistResource> series)
|
||||||
{
|
{
|
||||||
var request = BuildRequest("editor");
|
var request = BuildRequest("editor");
|
||||||
request.AddBody(series);
|
request.AddBody(series);
|
||||||
return Put<List<SeriesResource>>(request);
|
return Put<List<ArtistResource>>(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK)
|
public ArtistResource Get(string slug, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
var request = BuildRequest(slug);
|
var request = BuildRequest(slug);
|
||||||
return Get<SeriesResource>(request, statusCode);
|
return Get<ArtistResource>(request, statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SystemInfoClient : ClientBase<SeriesResource>
|
public class SystemInfoClient : ClientBase<ArtistResource>
|
||||||
{
|
{
|
||||||
public SystemInfoClient(IRestClient restClient, string apiKey)
|
public SystemInfoClient(IRestClient restClient, string apiKey)
|
||||||
: base(restClient, apiKey)
|
: base(restClient, apiKey)
|
20
src/NzbDrone.Integration.Test/Client/TrackClient.cs
Normal file
20
src/NzbDrone.Integration.Test/Client/TrackClient.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Api.Tracks;
|
||||||
|
using RestSharp;
|
||||||
|
|
||||||
|
namespace NzbDrone.Integration.Test.Client
|
||||||
|
{
|
||||||
|
public class TrackClient : ClientBase<TrackResource>
|
||||||
|
{
|
||||||
|
public TrackClient(IRestClient restClient, string apiKey)
|
||||||
|
: base(restClient, apiKey, "track")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TrackResource> GetTracksInArtist(int artistId)
|
||||||
|
{
|
||||||
|
var request = BuildRequest("?artistId=" + artistId.ToString());
|
||||||
|
return Get<List<TrackResource>>(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Integration.Test
|
||||||
var logFile = Path.Combine(_runner.AppData, "logs", "Lidarr.trace.txt");
|
var logFile = Path.Combine(_runner.AppData, "logs", "Lidarr.trace.txt");
|
||||||
var logLines = File.ReadAllLines(logFile);
|
var logLines = File.ReadAllLines(logFile);
|
||||||
|
|
||||||
var result = Series.InvalidPost(new Api.Series.SeriesResource());
|
var result = Artist.InvalidPost(new Api.Music.ArtistResource());
|
||||||
|
|
||||||
logLines = File.ReadAllLines(logFile).Skip(logLines.Length).ToArray();
|
logLines = File.ReadAllLines(logFile).Skip(logLines.Length).ToArray();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Integration.Test
|
||||||
{
|
{
|
||||||
protected NzbDroneRunner _runner;
|
protected NzbDroneRunner _runner;
|
||||||
|
|
||||||
public override string SeriesRootFolder => GetTempDirectory("SeriesRootFolder");
|
public override string ArtistRootFolder => GetTempDirectory("ArtistRootFolder");
|
||||||
|
|
||||||
protected override string RootUrl => "http://localhost:8686/";
|
protected override string RootUrl => "http://localhost:8686/";
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,18 @@ using NzbDrone.Api.Commands;
|
||||||
using NzbDrone.Api.Config;
|
using NzbDrone.Api.Config;
|
||||||
using NzbDrone.Api.DownloadClient;
|
using NzbDrone.Api.DownloadClient;
|
||||||
using NzbDrone.Api.EpisodeFiles;
|
using NzbDrone.Api.EpisodeFiles;
|
||||||
|
using NzbDrone.Api.TrackFiles;
|
||||||
using NzbDrone.Api.Episodes;
|
using NzbDrone.Api.Episodes;
|
||||||
using NzbDrone.Api.History;
|
using NzbDrone.Api.History;
|
||||||
using NzbDrone.Api.Profiles;
|
using NzbDrone.Api.Profiles;
|
||||||
using NzbDrone.Api.RootFolders;
|
using NzbDrone.Api.RootFolders;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Music;
|
||||||
|
using NzbDrone.Api.Albums;
|
||||||
using NzbDrone.Api.Tags;
|
using NzbDrone.Api.Tags;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv.Commands;
|
using NzbDrone.Core.Music.Commands;
|
||||||
using NzbDrone.Integration.Test.Client;
|
using NzbDrone.Integration.Test.Client;
|
||||||
using NzbDrone.SignalR;
|
using NzbDrone.SignalR;
|
||||||
using NzbDrone.Test.Common.Categories;
|
using NzbDrone.Test.Common.Categories;
|
||||||
|
@ -41,6 +43,7 @@ namespace NzbDrone.Integration.Test
|
||||||
public CommandClient Commands;
|
public CommandClient Commands;
|
||||||
public DownloadClientClient DownloadClients;
|
public DownloadClientClient DownloadClients;
|
||||||
public EpisodeClient Episodes;
|
public EpisodeClient Episodes;
|
||||||
|
public TrackClient Tracks;
|
||||||
public ClientBase<HistoryResource> History;
|
public ClientBase<HistoryResource> History;
|
||||||
public ClientBase<HostConfigResource> HostConfig;
|
public ClientBase<HostConfigResource> HostConfig;
|
||||||
public IndexerClient Indexers;
|
public IndexerClient Indexers;
|
||||||
|
@ -49,7 +52,7 @@ namespace NzbDrone.Integration.Test
|
||||||
public ClientBase<ProfileResource> Profiles;
|
public ClientBase<ProfileResource> Profiles;
|
||||||
public ReleaseClient Releases;
|
public ReleaseClient Releases;
|
||||||
public ClientBase<RootFolderResource> RootFolders;
|
public ClientBase<RootFolderResource> RootFolders;
|
||||||
public SeriesClient Series;
|
public ArtistClient Artist;
|
||||||
public ClientBase<TagResource> Tags;
|
public ClientBase<TagResource> Tags;
|
||||||
public ClientBase<EpisodeResource> WantedMissing;
|
public ClientBase<EpisodeResource> WantedMissing;
|
||||||
public ClientBase<EpisodeResource> WantedCutoffUnmet;
|
public ClientBase<EpisodeResource> WantedCutoffUnmet;
|
||||||
|
@ -71,7 +74,7 @@ namespace NzbDrone.Integration.Test
|
||||||
|
|
||||||
public string TempDirectory { get; private set; }
|
public string TempDirectory { get; private set; }
|
||||||
|
|
||||||
public abstract string SeriesRootFolder { get; }
|
public abstract string ArtistRootFolder { get; }
|
||||||
|
|
||||||
protected abstract string RootUrl { get; }
|
protected abstract string RootUrl { get; }
|
||||||
|
|
||||||
|
@ -109,7 +112,7 @@ namespace NzbDrone.Integration.Test
|
||||||
Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey);
|
Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey);
|
||||||
Releases = new ReleaseClient(RestClient, ApiKey);
|
Releases = new ReleaseClient(RestClient, ApiKey);
|
||||||
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
|
RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
|
||||||
Series = new SeriesClient(RestClient, ApiKey);
|
Artist = new ArtistClient(RestClient, ApiKey);
|
||||||
Tags = new ClientBase<TagResource>(RestClient, ApiKey);
|
Tags = new ClientBase<TagResource>(RestClient, ApiKey);
|
||||||
WantedMissing = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/missing");
|
WantedMissing = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/missing");
|
||||||
WantedCutoffUnmet = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/cutoff");
|
WantedCutoffUnmet = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/cutoff");
|
||||||
|
@ -202,22 +205,21 @@ namespace NzbDrone.Integration.Test
|
||||||
Assert.Fail("Timed on wait");
|
Assert.Fail("Timed on wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeriesResource EnsureSeries(int tvdbId, string seriesTitle, bool? monitored = null)
|
public ArtistResource EnsureArtist(string lidarrId, string artsitName, bool? monitored = null)
|
||||||
{
|
{
|
||||||
var result = Series.All().FirstOrDefault(v => v.TvdbId == tvdbId);
|
var result = Artist.All().FirstOrDefault(v => v.ForeignArtistId == lidarrId);
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
var lookup = Series.Lookup("tvdb:" + tvdbId);
|
var lookup = Artist.Lookup("lidarr:" + lidarrId);
|
||||||
var series = lookup.First();
|
var artist = lookup.First();
|
||||||
series.ProfileId = 1;
|
artist.ProfileId = 1;
|
||||||
series.Path = Path.Combine(SeriesRootFolder, series.Title);
|
artist.Path = Path.Combine(ArtistRootFolder, artist.Name);
|
||||||
series.Monitored = true;
|
artist.Monitored = true;
|
||||||
series.Seasons.ForEach(v => v.Monitored = true);
|
artist.AddOptions = new Core.Music.AddArtistOptions();
|
||||||
series.AddOptions = new Core.Tv.AddSeriesOptions();
|
Directory.CreateDirectory(artist.Path);
|
||||||
Directory.CreateDirectory(series.Path);
|
|
||||||
|
|
||||||
result = Series.Post(series);
|
result = Artist.Post(artist);
|
||||||
Commands.WaitAll();
|
Commands.WaitAll();
|
||||||
WaitForCompletion(() => Episodes.GetEpisodesInSeries(result.Id).Count > 0);
|
WaitForCompletion(() => Episodes.GetEpisodesInSeries(result.Id).Count > 0);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +233,7 @@ namespace NzbDrone.Integration.Test
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Seasons.ForEach(season =>
|
result.Albums.ForEach(season =>
|
||||||
{
|
{
|
||||||
if (season.Monitored != monitored.Value)
|
if (season.Monitored != monitored.Value)
|
||||||
{
|
{
|
||||||
|
@ -242,43 +244,44 @@ namespace NzbDrone.Integration.Test
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
Series.Put(result);
|
Artist.Put(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnsureNoSeries(int tvdbId, string seriesTitle)
|
|
||||||
|
public void EnsureNoArtsit(string lidarrId, string artistTitle)
|
||||||
{
|
{
|
||||||
var result = Series.All().FirstOrDefault(v => v.TvdbId == tvdbId);
|
var result = Artist.All().FirstOrDefault(v => v.ForeignArtistId == lidarrId);
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
Series.Delete(result.Id);
|
Artist.Delete(result.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EpisodeFileResource EnsureEpisodeFile(SeriesResource series, int season, int episode, Quality quality)
|
public TrackFileResource EnsureTrackFile(ArtistResource artist, int albumId, int track, Quality quality)
|
||||||
{
|
{
|
||||||
var result = Episodes.GetEpisodesInSeries(series.Id).Single(v => v.SeasonNumber == season && v.EpisodeNumber == episode);
|
var result = Tracks.GetTracksInArtist(artist.Id).Single(v => v.AlbumId == albumId && v.TrackNumber == track);
|
||||||
|
|
||||||
if (result.EpisodeFile == null)
|
if (result.TrackFile == null)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(SeriesRootFolder, series.Title, string.Format("Series.S{0}E{1}.{2}.mkv", season, episode, quality.Name));
|
var path = Path.Combine(ArtistRootFolder, artist.Name, string.Format("{0} - {1} - Track.mp3", track, artist.Name));
|
||||||
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
File.WriteAllText(path, "Fake Episode");
|
File.WriteAllText(path, "Fake Track");
|
||||||
|
|
||||||
Commands.PostAndWait(new CommandResource { Name = "refreshseries", Body = new RefreshSeriesCommand(series.Id) });
|
Commands.PostAndWait(new CommandResource { Name = "refreshseries", Body = new RefreshArtistCommand(artist.Id) });
|
||||||
Commands.WaitAll();
|
Commands.WaitAll();
|
||||||
|
|
||||||
result = Episodes.GetEpisodesInSeries(series.Id).Single(v => v.SeasonNumber == season && v.EpisodeNumber == episode);
|
result = Tracks.GetTracksInArtist(artist.Id).Single(v => v.AlbumId == albumId && v.TrackNumber == track);
|
||||||
|
|
||||||
result.EpisodeFile.Should().NotBeNull();
|
result.TrackFile.Should().NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.EpisodeFile;
|
return result.TrackFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileResource EnsureProfileCutoff(int profileId, Quality cutoff)
|
public ProfileResource EnsureProfileCutoff(int profileId, Quality cutoff)
|
||||||
|
|
|
@ -103,21 +103,23 @@
|
||||||
<Compile Include="ApiTests\CalendarFixture.cs" />
|
<Compile Include="ApiTests\CalendarFixture.cs" />
|
||||||
<Compile Include="ApiTests\BlacklistFixture.cs" />
|
<Compile Include="ApiTests\BlacklistFixture.cs" />
|
||||||
<Compile Include="ApiTests\DownloadClientFixture.cs" />
|
<Compile Include="ApiTests\DownloadClientFixture.cs" />
|
||||||
<Compile Include="ApiTests\EpisodeFileFixture.cs" />
|
<Compile Include="ApiTests\TrackFileFixture.cs" />
|
||||||
<Compile Include="ApiTests\FileSystemFixture.cs" />
|
<Compile Include="ApiTests\FileSystemFixture.cs" />
|
||||||
<Compile Include="ApiTests\SeriesLookupFixture.cs" />
|
<Compile Include="ApiTests\ArtistFixture.cs" />
|
||||||
|
<Compile Include="ApiTests\ArtistLookupFixture.cs" />
|
||||||
<Compile Include="ApiTests\WantedFixture.cs" />
|
<Compile Include="ApiTests\WantedFixture.cs" />
|
||||||
<Compile Include="Client\ClientBase.cs" />
|
<Compile Include="Client\ClientBase.cs" />
|
||||||
|
<Compile Include="Client\TrackClient.cs" />
|
||||||
<Compile Include="Client\EpisodeClient.cs" />
|
<Compile Include="Client\EpisodeClient.cs" />
|
||||||
<Compile Include="Client\IndexerClient.cs" />
|
<Compile Include="Client\IndexerClient.cs" />
|
||||||
<Compile Include="Client\DownloadClientClient.cs" />
|
<Compile Include="Client\DownloadClientClient.cs" />
|
||||||
<Compile Include="Client\NotificationClient.cs" />
|
<Compile Include="Client\NotificationClient.cs" />
|
||||||
<Compile Include="Client\CommandClient.cs" />
|
<Compile Include="Client\CommandClient.cs" />
|
||||||
<Compile Include="Client\ReleaseClient.cs" />
|
<Compile Include="Client\ReleaseClient.cs" />
|
||||||
<Compile Include="Client\SeriesClient.cs" />
|
<Compile Include="Client\ArtistClient.cs" />
|
||||||
<Compile Include="ApiTests\CommandFixture.cs" />
|
<Compile Include="ApiTests\CommandFixture.cs" />
|
||||||
<Compile Include="CorsFixture.cs" />
|
<Compile Include="CorsFixture.cs" />
|
||||||
<Compile Include="ApiTests\EpisodeFixture.cs" />
|
<Compile Include="ApiTests\TrackFixture.cs" />
|
||||||
<Compile Include="ApiTests\HistoryFixture.cs" />
|
<Compile Include="ApiTests\HistoryFixture.cs" />
|
||||||
<Compile Include="ApiTests\IndexerFixture.cs" />
|
<Compile Include="ApiTests\IndexerFixture.cs" />
|
||||||
<Compile Include="HttpLogFixture.cs" />
|
<Compile Include="HttpLogFixture.cs" />
|
||||||
|
@ -129,8 +131,7 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ApiTests\ReleaseFixture.cs" />
|
<Compile Include="ApiTests\ReleaseFixture.cs" />
|
||||||
<Compile Include="ApiTests\RootFolderFixture.cs" />
|
<Compile Include="ApiTests\RootFolderFixture.cs" />
|
||||||
<Compile Include="ApiTests\SeriesEditorFixture.cs" />
|
<Compile Include="ApiTests\ArtistEditorFixture.cs" />
|
||||||
<Compile Include="ApiTests\SeriesFixture.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\NzbDrone.Test.Common\App.config">
|
<None Include="..\NzbDrone.Test.Common\App.config">
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<a href="{{route}}">{{artistName}}</a>
|
<a href="{{route}}">{{name}}</a>
|
||||||
|
|
|
@ -12,7 +12,7 @@ var Collection = PagableCollection.extend({
|
||||||
|
|
||||||
state : {
|
state : {
|
||||||
pageSize : 15,
|
pageSize : 15,
|
||||||
sortKey : 'airDateUtc',
|
sortKey : 'releaseDate',
|
||||||
order : 1
|
order : 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ var Collection = PagableCollection.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
sortMappings : {
|
sortMappings : {
|
||||||
'series' : { sortKey : 'series.sortTitle' }
|
'artist' : { sortKey : 'artist.sortName' }
|
||||||
},
|
},
|
||||||
|
|
||||||
parseState : function(resp) {
|
parseState : function(resp) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ var Marionette = require('marionette');
|
||||||
var Backgrid = require('backgrid');
|
var Backgrid = require('backgrid');
|
||||||
var MissingCollection = require('./MissingCollection');
|
var MissingCollection = require('./MissingCollection');
|
||||||
var SelectAllCell = require('../../Cells/SelectAllCell');
|
var SelectAllCell = require('../../Cells/SelectAllCell');
|
||||||
var SeriesTitleCell = require('../../Cells/SeriesTitleCell');
|
var ArtistTitleCell = require('../../Cells/ArtistTitleCell');
|
||||||
var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
|
var EpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
|
||||||
var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
|
var EpisodeTitleCell = require('../../Cells/EpisodeTitleCell');
|
||||||
var RelativeDateCell = require('../../Cells/RelativeDateCell');
|
var RelativeDateCell = require('../../Cells/RelativeDateCell');
|
||||||
|
@ -40,10 +40,10 @@ module.exports = Marionette.Layout.extend({
|
||||||
sortable : false
|
sortable : false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'series',
|
name : 'artist',
|
||||||
label : 'Artist',
|
label : 'Artist',
|
||||||
cell : SeriesTitleCell,
|
cell : ArtistTitleCell,
|
||||||
sortValue : 'series.sortTitle'
|
sortValue : 'artist.sortName'
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// name : 'this',
|
// name : 'this',
|
||||||
|
@ -58,7 +58,7 @@ module.exports = Marionette.Layout.extend({
|
||||||
sortable : false
|
sortable : false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'airDateUtc',
|
name : 'releaseDate',
|
||||||
label : 'Release Date',
|
label : 'Release Date',
|
||||||
cell : RelativeDateCell
|
cell : RelativeDateCell
|
||||||
},
|
},
|
||||||
|
@ -195,7 +195,7 @@ module.exports = Marionette.Layout.extend({
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
Messenger.show({
|
Messenger.show({
|
||||||
type : 'error',
|
type : 'error',
|
||||||
message : 'No episodes selected'
|
message : 'No albums selected'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,8 @@ module.exports = Marionette.Layout.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_searchMissing : function() {
|
_searchMissing : function() {
|
||||||
if (window.confirm('Are you sure you want to search for {0} missing episodes? '.format(this.collection.state.totalRecords) +
|
if (window.confirm('Are you sure you want to search for {0} missing albums? '.format(this.collection.state.totalRecords) +
|
||||||
'One API request to each indexer will be used for each episode. ' + 'This cannot be stopped once started.')) {
|
'One API request to each indexer will be used for each album. ' + 'This cannot be stopped once started.')) {
|
||||||
CommandController.Execute('missingEpisodeSearch', { name : 'missingEpisodeSearch' });
|
CommandController.Execute('missingEpisodeSearch', { name : 'missingEpisodeSearch' });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -217,7 +217,7 @@ module.exports = Marionette.Layout.extend({
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
Messenger.show({
|
Messenger.show({
|
||||||
type : 'error',
|
type : 'error',
|
||||||
message : 'No episodes selected'
|
message : 'No albums selected'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue