Episode and Season monitored toggling works again
This commit is contained in:
parent
75371c4e72
commit
9f0138328b
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
|
@ -15,6 +16,7 @@ namespace NzbDrone.Api.Episodes
|
|||
|
||||
GetResourceAll = GetEpisodes;
|
||||
UpdateResource = SetMonitored;
|
||||
GetResourceById = GetEpisode;
|
||||
}
|
||||
|
||||
private List<EpisodeResource> GetEpisodes()
|
||||
|
@ -33,5 +35,10 @@ namespace NzbDrone.Api.Episodes
|
|||
{
|
||||
_episodeService.SetEpisodeMonitored(episodeResource.Id, episodeResource.Monitored);
|
||||
}
|
||||
|
||||
private EpisodeResource GetEpisode(int id)
|
||||
{
|
||||
return _episodeService.GetEpisode(id).InjectTo<EpisodeResource>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Api.Seasons
|
||||
|
@ -13,6 +14,7 @@ namespace NzbDrone.Api.Seasons
|
|||
_seasonService = seasonService;
|
||||
|
||||
GetResourceAll = GetSeasons;
|
||||
GetResourceById = GetSeason;
|
||||
UpdateResource = Update;
|
||||
|
||||
Post["/pass"] = x => SetSeasonPass();
|
||||
|
@ -30,6 +32,11 @@ namespace NzbDrone.Api.Seasons
|
|||
return ToListResource(() => _seasonService.GetAllSeasons());
|
||||
}
|
||||
|
||||
private SeasonResource GetSeason(int id)
|
||||
{
|
||||
return _seasonService.Get(id).InjectTo<SeasonResource>();
|
||||
}
|
||||
|
||||
private void Update(SeasonResource seasonResource)
|
||||
{
|
||||
_seasonService.SetMonitored(seasonResource.SeriesId, seasonResource.SeasonNumber, seasonResource.Monitored);
|
||||
|
|
Binary file not shown.
|
@ -42,13 +42,19 @@ namespace NzbDrone.Integration.Test.Client
|
|||
return Post<TResource>(request);
|
||||
}
|
||||
|
||||
public TResource Put(TResource body)
|
||||
{
|
||||
var request = BuildRequest();
|
||||
request.AddBody(body);
|
||||
return Put<TResource>(request);
|
||||
}
|
||||
|
||||
public TResource Get(int id, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
var request = BuildRequest(id.ToString());
|
||||
return Get<TResource>(request, statusCode);
|
||||
}
|
||||
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
var request = BuildRequest(id.ToString());
|
||||
|
@ -82,6 +88,12 @@ namespace NzbDrone.Integration.Test.Client
|
|||
return Execute<T>(request, statusCode);
|
||||
}
|
||||
|
||||
public T Put<T>(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.Accepted) where T : class, new()
|
||||
{
|
||||
request.Method = Method.PUT;
|
||||
return Execute<T>(request, statusCode);
|
||||
}
|
||||
|
||||
public void Delete(IRestRequest request, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
request.Method = Method.DELETE;
|
||||
|
@ -109,13 +121,11 @@ namespace NzbDrone.Integration.Test.Client
|
|||
return Json.Deserialize<T>(response.Content);
|
||||
}
|
||||
|
||||
|
||||
private static void AssertDisableCache(IList<Parameter> headers)
|
||||
{
|
||||
headers.Single(c => c.Name == "Cache-Control").Value.Should().Be("no-cache, no-store, must-revalidate");
|
||||
headers.Single(c => c.Name == "Pragma").Value.Should().Be("no-cache");
|
||||
headers.Single(c => c.Name == "Expires").Value.Should().Be("0");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using NzbDrone.Api.Episodes;
|
||||
using NzbDrone.Api.Series;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
{
|
||||
public class EpisodeClient : ClientBase<EpisodeResource>
|
||||
{
|
||||
public EpisodeClient(IRestClient restClient)
|
||||
: base(restClient, "episodes")
|
||||
{
|
||||
}
|
||||
|
||||
public List<EpisodeResource> GetEpisodesInSeries(int seriesId)
|
||||
{
|
||||
var request = BuildRequest("?seriesId=" + seriesId.ToString());
|
||||
return Get<List<EpisodeResource>>(request);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using NzbDrone.Api.Episodes;
|
||||
using NzbDrone.Api.Seasons;
|
||||
using RestSharp;
|
||||
|
||||
namespace NzbDrone.Integration.Test.Client
|
||||
{
|
||||
public class SeasonClient : ClientBase<SeasonResource>
|
||||
{
|
||||
public SeasonClient(IRestClient restClient)
|
||||
: base(restClient)
|
||||
{
|
||||
}
|
||||
|
||||
public List<SeasonResource> GetSeasonsInSeries(int seriesId)
|
||||
{
|
||||
var request = BuildRequest("?seriesId=" + seriesId.ToString());
|
||||
return Get<List<SeasonResource>>(request);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Api.Series;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class EpisodeIntegrationTests : IntegrationTest
|
||||
{
|
||||
private SeriesResource GivenSeriesWithEpisodes()
|
||||
{
|
||||
var series = Series.Lookup("archer").First();
|
||||
|
||||
series.QualityProfileId = 1;
|
||||
series.Path = @"C:\Test\Archer";
|
||||
|
||||
series = Series.Post(series);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (Episodes.GetEpisodesInSeries(series.Id).Count > 0)
|
||||
{
|
||||
return series;
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_all_episodes_in_series()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
Episodes.GetEpisodesInSeries(series.Id).Count.Should().BeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_a_single_episode()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
||||
|
||||
Episodes.Get(episodes.First().Id).Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_set_monitor_status_via_api()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var episodes = Episodes.GetEpisodesInSeries(series.Id);
|
||||
var updatedEpisode = episodes.First();
|
||||
updatedEpisode.Monitored = false;
|
||||
|
||||
Episodes.Put(updatedEpisode).Monitored.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using NLog.Config;
|
|||
using NLog.Targets;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Api.Commands;
|
||||
using NzbDrone.Api.Episodes;
|
||||
using NzbDrone.Api.RootFolders;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Integration.Test.Client;
|
||||
|
@ -22,6 +23,8 @@ namespace NzbDrone.Integration.Test
|
|||
protected ClientBase<CommandResource> Commands;
|
||||
protected ReleaseClient Releases;
|
||||
protected IndexerClient Indexers;
|
||||
protected EpisodeClient Episodes;
|
||||
protected SeasonClient Seasons;
|
||||
|
||||
private NzbDroneRunner _runner;
|
||||
|
||||
|
@ -57,6 +60,8 @@ namespace NzbDrone.Integration.Test
|
|||
RootFolders = new ClientBase<RootFolderResource>(RestClient);
|
||||
Commands = new ClientBase<CommandResource>(RestClient);
|
||||
Indexers = new IndexerClient(RestClient);
|
||||
Episodes = new EpisodeClient(RestClient);
|
||||
Seasons = new SeasonClient(RestClient);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
|
|
@ -93,10 +93,14 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client\ClientBase.cs" />
|
||||
<Compile Include="Client\SeasonClient.cs" />
|
||||
<Compile Include="Client\EpisodeClient.cs" />
|
||||
<Compile Include="Client\IndexerClient.cs" />
|
||||
<Compile Include="Client\ReleaseClient.cs" />
|
||||
<Compile Include="Client\SeriesClient.cs" />
|
||||
<Compile Include="CommandIntegerationTests.cs" />
|
||||
<Compile Include="SeasonIntegrationTests.cs" />
|
||||
<Compile Include="EpisodeIntegrationTests.cs" />
|
||||
<Compile Include="IndexerIntegrationFixture.cs" />
|
||||
<Compile Include="IntegrationTestDirectoryInfo.cs" />
|
||||
<Compile Include="NzbDroneRunner.cs" />
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Api.Series;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Integration.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class SeasonIntegrationTests : IntegrationTest
|
||||
{
|
||||
private SeriesResource GivenSeriesWithEpisodes()
|
||||
{
|
||||
var series = Series.Lookup("archer").First();
|
||||
|
||||
series.QualityProfileId = 1;
|
||||
series.Path = @"C:\Test\Archer";
|
||||
|
||||
series = Series.Post(series);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (Seasons.GetSeasonsInSeries(series.Id).Count > 0)
|
||||
{
|
||||
return series;
|
||||
}
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_all_seasons_in_series()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
Seasons.GetSeasonsInSeries(series.Id).Count.Should().BeGreaterThan(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_get_a_single_season()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var seasons = Seasons.GetSeasonsInSeries(series.Id);
|
||||
|
||||
Seasons.Get(seasons.First().Id).Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_set_monitor_status_via_api()
|
||||
{
|
||||
var series = GivenSeriesWithEpisodes();
|
||||
var seasons = Seasons.GetSeasonsInSeries(series.Id);
|
||||
var updatedSeason = seasons.First();
|
||||
updatedSeason.Monitored = false;
|
||||
|
||||
Seasons.Put(updatedSeason).Monitored.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue