mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Episode and Season monitored toggling works again
This commit is contained in:
parent
429460dd5e
commit
6bea671a1a
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.Mapping;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
@ -15,6 +16,7 @@ public EpisodeModule(IEpisodeService episodeService)
|
||||
|
||||
GetResourceAll = GetEpisodes;
|
||||
UpdateResource = SetMonitored;
|
||||
GetResourceById = GetEpisode;
|
||||
}
|
||||
|
||||
private List<EpisodeResource> GetEpisodes()
|
||||
@ -33,5 +35,10 @@ private void SetMonitored(EpisodeResource episodeResource)
|
||||
{
|
||||
_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 @@ public SeasonModule(ISeasonService seasonService)
|
||||
_seasonService = seasonService;
|
||||
|
||||
GetResourceAll = GetSeasons;
|
||||
GetResourceById = GetSeason;
|
||||
UpdateResource = Update;
|
||||
|
||||
Post["/pass"] = x => SetSeasonPass();
|
||||
@ -30,6 +32,11 @@ private List<SeasonResource> GetSeasons()
|
||||
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 @@ public TResource Post(TResource body)
|
||||
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 @@ protected RestRequest BuildRequest(string command = "")
|
||||
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 @@ public void Delete(IRestRequest request, HttpStatusCode statusCode = HttpStatusC
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
22
NzbDrone.Integration.Test/Client/EpisodeClient.cs
Normal file
22
NzbDrone.Integration.Test/Client/EpisodeClient.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
22
NzbDrone.Integration.Test/Client/SeasonClient.cs
Normal file
22
NzbDrone.Integration.Test/Client/SeasonClient.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
60
NzbDrone.Integration.Test/EpisodeIntegrationTests.cs
Normal file
60
NzbDrone.Integration.Test/EpisodeIntegrationTests.cs
Normal file
@ -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.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 @@ public abstract class IntegrationTest
|
||||
protected ClientBase<CommandResource> Commands;
|
||||
protected ReleaseClient Releases;
|
||||
protected IndexerClient Indexers;
|
||||
protected EpisodeClient Episodes;
|
||||
protected SeasonClient Seasons;
|
||||
|
||||
private NzbDroneRunner _runner;
|
||||
|
||||
@ -57,6 +60,8 @@ private void InitRestClients()
|
||||
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" />
|
||||
|
60
NzbDrone.Integration.Test/SeasonIntegrationTests.cs
Normal file
60
NzbDrone.Integration.Test/SeasonIntegrationTests.cs
Normal file
@ -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
Block a user