mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Removed upcoming, fixed broken test
This commit is contained in:
parent
82ae91dd6e
commit
8a3edaebbf
@ -5,8 +5,6 @@
|
||||
using NzbDrone.Api.QualityType;
|
||||
using NzbDrone.Api.Resolvers;
|
||||
using NzbDrone.Api.Series;
|
||||
using NzbDrone.Api.Upcoming;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@ -43,11 +41,6 @@ public static void InitializeAutomapper()
|
||||
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting))
|
||||
.ForMember(dest => dest.NextAiring, opt => opt.ResolveUsing<NextAiringResolver>());
|
||||
|
||||
//Upcoming
|
||||
Mapper.CreateMap<Episode, UpcomingResource>()
|
||||
.ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title))
|
||||
.ForMember(dest => dest.EpisodeTitle, opt => opt.MapFrom(src => src.Title));
|
||||
|
||||
//Calendar
|
||||
Mapper.CreateMap<Episode, CalendarResource>()
|
||||
.ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title))
|
||||
|
@ -17,10 +17,10 @@ public CalendarModule(EpisodeService episodeService)
|
||||
: base("/calendar")
|
||||
{
|
||||
_episodeService = episodeService;
|
||||
Get["/"] = x => Calendar();
|
||||
Get["/"] = x => GetEpisodesBetweenStartAndEndDate();
|
||||
}
|
||||
|
||||
private Response Calendar()
|
||||
private Response GetEpisodesBetweenStartAndEndDate()
|
||||
{
|
||||
var start = DateTime.Today;
|
||||
var end = DateTime.Today.AddDays(7);
|
||||
|
@ -142,8 +142,6 @@
|
||||
<Compile Include="Resolvers\AllowedToQualitiesResolver.cs" />
|
||||
<Compile Include="Resolvers\QualitiesToAllowedResolver.cs" />
|
||||
<Compile Include="Resolvers\QualityTypesToIntResolver.cs" />
|
||||
<Compile Include="Upcoming\UpcomingModule.cs" />
|
||||
<Compile Include="Upcoming\UpcomingResource.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using FluentValidation;
|
||||
using Nancy;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Api.Series;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.Upcoming
|
||||
{
|
||||
public class UpcomingModule : NzbDroneApiModule
|
||||
{
|
||||
private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider;
|
||||
|
||||
public UpcomingModule(UpcomingEpisodesProvider upcomingEpisodesProvider)
|
||||
: base("/Upcoming")
|
||||
{
|
||||
_upcomingEpisodesProvider = upcomingEpisodesProvider;
|
||||
Get["/"] = x => Upcoming();
|
||||
}
|
||||
|
||||
private Response Upcoming()
|
||||
{
|
||||
var upcoming = _upcomingEpisodesProvider.UpcomingEpisodes();
|
||||
return Mapper.Map<List<Episode>, List<UpcomingResource>>(upcoming).AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NzbDrone.Api.QualityProfiles;
|
||||
using NzbDrone.Core.Model;
|
||||
|
||||
namespace NzbDrone.Api.Upcoming
|
||||
{
|
||||
public class UpcomingResource
|
||||
{
|
||||
public Int32 SeriesId { get; set; }
|
||||
public String SeriesTitle { get; set; }
|
||||
|
||||
public Int32 EpisodeId { get; set; }
|
||||
public String EpisodeTitle { get; set; }
|
||||
public Int32 SeasonNumber { get; set; }
|
||||
public Int32 EpisodeNumber { get; set; }
|
||||
public DateTime? AirTime { get; set; }
|
||||
public Int32 Status { get; set; }
|
||||
public String Overview { get; set; }
|
||||
}
|
||||
}
|
@ -29,10 +29,9 @@ public void series_specific_scan_should_scan_series()
|
||||
.With(s => s.Id = 12)
|
||||
.Build();
|
||||
|
||||
|
||||
Mocker.GetMock<ISeriesRepository>()
|
||||
.Setup(p => p.Get(series.Id));
|
||||
|
||||
.Setup(p => p.Get(series.Id))
|
||||
.Returns(series);
|
||||
|
||||
Mocker.GetMock<DiskScanProvider>()
|
||||
.Setup(p => p.Scan(series))
|
||||
@ -120,14 +119,10 @@ public void job_with_no_target_should_scan_series_with_episodes()
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Returns(new List<EpisodeFile>());
|
||||
|
||||
|
||||
Mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), null);
|
||||
|
||||
|
||||
|
||||
Mocker.VerifyAllMocks();
|
||||
Mocker.GetMock<DiskScanProvider>().Verify(s => s.Scan(It.IsAny<Series>()), Times.Exactly(2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -232,7 +232,6 @@
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\ImportFileFixture.cs" />
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="ProviderTests\UpcomingEpisodesProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\MediaFileProviderTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="Framework\SqlCeTest.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
|
@ -1,91 +0,0 @@
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class UpcomingEpisodesProviderTest : SqlCeTest
|
||||
{
|
||||
private IList<Episode> episodes;
|
||||
private Series series;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
episodes = Builder<Episode>.CreateListOfSize(6)
|
||||
.All()
|
||||
.With(e => e.SeriesId = 1)
|
||||
.With(e => e.Ignored = false)
|
||||
.TheFirst(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
|
||||
.TheNext(1)
|
||||
.With(e => e.AirDate = DateTime.Today)
|
||||
.TheNext(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(1))
|
||||
.TheNext(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(2))
|
||||
.TheNext(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(7))
|
||||
.TheNext(1)
|
||||
.With(e => e.AirDate = DateTime.Today.AddDays(9))
|
||||
.Build();
|
||||
|
||||
series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 1)
|
||||
.And(c => c.Monitored = true)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.Insert(series);
|
||||
}
|
||||
|
||||
private void WithIgnoredEpisodes()
|
||||
{
|
||||
episodes.ToList().ForEach(c => c.Ignored = true);
|
||||
Db.UpdateMany(episodes);
|
||||
}
|
||||
|
||||
private void WithIgnoredSeries()
|
||||
{
|
||||
series.Monitored = false;
|
||||
Db.Update(series);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_UpcomingEpisodes()
|
||||
{
|
||||
var result = Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_UpcomingEpisodes_should_skip_ingored()
|
||||
{
|
||||
WithIgnoredEpisodes();
|
||||
Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_UpcomingEpisodes_should_skip_unmonitored_series()
|
||||
{
|
||||
WithIgnoredSeries();
|
||||
Mocker.Resolve<UpcomingEpisodesProvider>().UpcomingEpisodes().Should().BeEmpty();
|
||||
}
|
||||
}
|
||||
}
|
@ -561,9 +561,6 @@
|
||||
<Compile Include="Providers\TwitterProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\UpcomingEpisodesProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\UpdateProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Tv;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class UpcomingEpisodesProvider
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
|
||||
public UpcomingEpisodesProvider(IDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
//Todo: Might be best if this is part of episode repo (when its there)
|
||||
public virtual List<Episode> UpcomingEpisodes()
|
||||
{
|
||||
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
|
||||
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
|
||||
WHERE Series.Monitored = 1 AND Ignored = 0 AND AirDate BETWEEN @0 AND @1"
|
||||
,DateTime.Today.AddDays(-1).Date, DateTime.Today.AddDays(8).Date);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user