Misc Cleanup

pull/6/head
Qstick 7 years ago
parent 8e626269d1
commit c9488351e4

@ -1,4 +1,4 @@
namespace Lidarr.Api.V1.Series
namespace Lidarr.Api.V1.Artist
{
public class AlternateTitleResource
{

@ -1,27 +0,0 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.DataAugmentation.DailySeries;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.DataAugmentation.DailySeries
{
[TestFixture]
[IntegrationTest]
public class DailySeriesDataProxyFixture : CoreTest<DailySeriesDataProxy>
{
[SetUp]
public void Setup()
{
UseRealHttp();
}
[Test]
public void should_get_list_of_daily_series()
{
var list = Subject.GetDailySeriesIds();
list.Should().NotBeEmpty();
list.Should().OnlyHaveUniqueItems();
}
}
}

@ -1,78 +0,0 @@
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerSearchTests
{
public class NzbSearchServiceFixture : CoreTest<NzbSearchService>
{
private List<IIndexer> _indexers;
private Series _searchTargetSeries;
[SetUp]
public void Setup()
{
_searchTargetSeries = Builder<Series>.CreateNew().BuildNew();
_indexers = new List<IIndexer>();
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
Mocker.SetConstant<IEnumerable<IIndexer>>(_indexers);
Mocker.GetMock<ISeriesService>().Setup(c => c.GetSeries(It.IsAny<int>()))
.Returns(_searchTargetSeries);
}
[Test]
public void should_call_fetch_on_all_indexers_at_the_same_time()
{
var counter = new ConcurrencyCounter(_indexers.Count);
Mocker.GetMock<IFetchFeedFromIndexers>().Setup(c => c.Fetch(It.IsAny<IIndexer>(), It.IsAny<SingleEpisodeSearchDefinition>()))
.Returns(new List<ReportInfo>())
.Callback((() => counter.SimulateWork(500)));
Mocker.GetMock<IIndexerService>().Setup(c => c.GetAvailableIndexers()).Returns(_indexers);
Mocker.GetMock<IMakeDownloadDecision>()
.Setup(c => c.GetSearchDecision(It.IsAny<IEnumerable<ReportInfo>>(), It.IsAny<SearchDefinitionBase>()))
.Returns(new List<DownloadDecision>());
Subject.SearchSingle(0, 0, 0);
counter.WaitForAllItems();
counter.MaxThreads.Should().Be(_indexers.Count);
}
}
}

@ -1,65 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerTests
{
public class FetchAndParseRssServiceFixture : CoreTest<FetchAndParseRssService>
{
private List<IIndexer> _indexers;
[SetUp]
public void Setup()
{
_indexers = new List<IIndexer>();
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
_indexers.Add(new Newznab());
Mocker.SetConstant<IEnumerable<IIndexer>>(_indexers);
}
[Test]
[Explicit]
public void should_call_fetch_on_all_indexers_at_the_same_time()
{
var counter = new ConcurrencyCounter(_indexers.Count);
Mocker.GetMock<IFetchFeedFromIndexers>().Setup(c => c.FetchRss(It.IsAny<IIndexer>()))
.Returns(new List<ReportInfo>())
.Callback((() => counter.SimulateWork(500)));
Mocker.GetMock<IIndexerService>().Setup(c => c.GetAvailableIndexers()).Returns(_indexers);
Subject.Fetch();
counter.WaitForAllItems();
counter.MaxThreads.Should().Be(_indexers.Count);
}
}
}

@ -103,7 +103,6 @@
<Compile Include="Blacklisting\BlacklistServiceFixture.cs" />
<Compile Include="Configuration\ConfigCachingFixture.cs" />
<Compile Include="Configuration\ConfigServiceFixture.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxyFixture.cs" />
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
<Compile Include="Datastore\Converters\BooleanIntConverterFixture.cs" />
<Compile Include="Datastore\Converters\CommandConverterFixture.cs" />

@ -1,7 +0,0 @@
namespace NzbDrone.Core.DataAugmentation.DailySeries
{
public class DailySeries
{
public int TvdbId { get; set; }
}
}

@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.Http;
namespace NzbDrone.Core.DataAugmentation.DailySeries
{
public interface IDailySeriesDataProxy
{
IEnumerable<int> GetDailySeriesIds();
}
public class DailySeriesDataProxy : IDailySeriesDataProxy
{
private readonly IHttpClient _httpClient;
private readonly IHttpRequestBuilderFactory _requestBuilder;
private readonly Logger _logger;
public DailySeriesDataProxy(IHttpClient httpClient, ILidarrCloudRequestBuilder requestBuilder, Logger logger)
{
_httpClient = httpClient;
_requestBuilder = requestBuilder.Services;
_logger = logger;
}
public IEnumerable<int> GetDailySeriesIds()
{
try
{
var dailySeriesRequest = _requestBuilder.Create()
.Resource("/dailyseries")
.Build();
var response = _httpClient.Get<List<DailySeries>>(dailySeriesRequest);
return response.Resource.Select(c => c.TvdbId);
}
catch (Exception ex)
{
_logger.Warn(ex, "Failed to get Daily Series");
return new List<int>();
}
}
}
}

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Cache;
namespace NzbDrone.Core.DataAugmentation.DailySeries
{
public interface IDailySeriesService
{
bool IsDailySeries(int tvdbid);
}
public class DailySeriesService : IDailySeriesService
{
private readonly IDailySeriesDataProxy _proxy;
private readonly ICached<List<int>> _cache;
public DailySeriesService(IDailySeriesDataProxy proxy, ICacheManager cacheManager)
{
_proxy = proxy;
_cache = cacheManager.GetCache<List<int>>(GetType());
}
public bool IsDailySeries(int tvdbid)
{
var dailySeries = _cache.Get("all", () => _proxy.GetDailySeriesIds().ToList(), TimeSpan.FromHours(1));
return dailySeries.Any(i => i == tvdbid);
}
}
}

@ -1,27 +0,0 @@
using System;
using NLog;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class DailyAudioMatchSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
public DailyAudioMatchSpecification(Logger logger)
{
_logger = logger;
}
public SpecificationPriority Priority => SpecificationPriority.Database;
public RejectionType Type => RejectionType.Permanent;
public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
{
throw new NotImplementedException();
// TODO Rework for Daily Audio/Podcasts
}
}
}

@ -79,14 +79,12 @@ namespace NzbDrone.Core.Music
public PagingSpec<Track> TracksWhereCutoffUnmet(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff)
{
pagingSpec.TotalRecords = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).GetRowCount();
pagingSpec.Records = EpisodesWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).ToList();
pagingSpec.TotalRecords = TracksWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).GetRowCount();
pagingSpec.Records = TracksWhereCutoffUnmetQuery(pagingSpec, qualitiesBelowCutoff).ToList();
return pagingSpec;
}
public void SetMonitoredFlat(Track track, bool monitored)
{
track.Monitored = monitored;
@ -109,22 +107,22 @@ namespace NzbDrone.Core.Music
mapper.ExecuteNonQuery(sql);
}
public void SetFileId(int episodeId, int fileId)
public void SetFileId(int trackId, int fileId)
{
SetFields(new Track { Id = episodeId, TrackFileId = fileId }, track => track.TrackFileId);
SetFields(new Track { Id = trackId, TrackFileId = fileId }, track => track.TrackFileId);
}
public PagingSpec<Track> TracksWithoutFiles(PagingSpec<Track> pagingSpec)
{
var currentTime = DateTime.UtcNow;
pagingSpec.TotalRecords = GetMissingEpisodesQuery(pagingSpec, currentTime).GetRowCount();
pagingSpec.Records = GetMissingEpisodesQuery(pagingSpec, currentTime).ToList();
pagingSpec.TotalRecords = GetMissingTracksQuery(pagingSpec, currentTime).GetRowCount();
pagingSpec.Records = GetMissingTracksQuery(pagingSpec, currentTime).ToList();
return pagingSpec;
}
private SortBuilder<Track> GetMissingEpisodesQuery(PagingSpec<Track> pagingSpec, DateTime currentTime)
private SortBuilder<Track> GetMissingTracksQuery(PagingSpec<Track> pagingSpec, DateTime currentTime)
{
return Query.Join<Track, Artist>(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id)
.Where(pagingSpec.FilterExpression)
@ -136,7 +134,7 @@ namespace NzbDrone.Core.Music
}
private SortBuilder<Track> EpisodesWhereCutoffUnmetQuery(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff)
private SortBuilder<Track> TracksWhereCutoffUnmetQuery(PagingSpec<Track> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff)
{
return Query.Join<Track, Artist>(JoinType.Inner, e => e.Artist, (e, s) => e.ArtistId == s.Id)
.Join<Track, TrackFile>(JoinType.Left, e => e.TrackFile, (e, s) => e.TrackFileId == s.Id)

@ -142,9 +142,6 @@
<Compile Include="Configuration\IConfigService.cs" />
<Compile Include="Configuration\InvalidConfigFileException.cs" />
<Compile Include="Configuration\ResetApiKeyCommand.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeries.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxy.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesService.cs" />
<Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\ConnectionStringFactory.cs" />
<Compile Include="Datastore\Converters\BooleanIntConverter.cs" />
@ -231,7 +228,6 @@
<Compile Include="DecisionEngine\Specifications\RssSync\HistorySpecification.cs" />
<Compile Include="DecisionEngine\Specifications\RssSync\MonitoredAlbumSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\RssSync\ProperSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\DailyAudioMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\AlbumRequestedSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\SeasonMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\Search\ArtistSpecification.cs" />

@ -1,7 +1,6 @@
using System.Threading;
using FluentAssertions;
using NUnit.Framework;
using Lidarr.Api.V1.Series;
using Lidarr.Api.V1.Artist;
using System.Linq;
using NzbDrone.Test.Common;
@ -11,12 +10,12 @@ namespace NzbDrone.Integration.Test.ApiTests
[TestFixture]
public class TrackFixture : IntegrationTest
{
private ArtistResource artist;
private ArtistResource _artist;
[SetUp]
public void Setup()
{
artist = GivenArtistWithTracks();
_artist = GivenArtistWithTracks();
}
private ArtistResource GivenArtistWithTracks()
@ -36,13 +35,13 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test]
public void should_be_able_to_get_all_tracks_in_artist()
{
Tracks.GetTracksInArtist(artist.Id).Count.Should().BeGreaterThan(0);
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);
var tracks = Tracks.GetTracksInArtist(_artist.Id);
Tracks.Get(tracks.First().Id).Should().NotBeNull();
}
@ -50,7 +49,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[Test]
public void should_be_able_to_set_monitor_status()
{
var tracks = Tracks.GetTracksInArtist(artist.Id);
var tracks = Tracks.GetTracksInArtist(_artist.Id);
var updatedTrack = tracks.First();
updatedTrack.Monitored = false;
@ -61,7 +60,7 @@ namespace NzbDrone.Integration.Test.ApiTests
[TearDown]
public void TearDown()
{
Artist.Delete(artist.Id);
Artist.Delete(_artist.Id);
Thread.Sleep(2000);
}
}

Loading…
Cancel
Save