mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-11-23 05:40:12 +00:00
Basic implementation of tv show changes, test might brake due to api instability and lack of data at this point for the feature
This commit is contained in:
parent
b68b4925fe
commit
f8b7248193
@ -24,14 +24,43 @@ namespace TMDbLib.Client
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of movie ids that have been edited.
|
||||
/// By default we show the last 24 hours and only 100 items per page.
|
||||
/// The maximum number of days that can be returned in a single request is 14.
|
||||
/// You can then use the movie changes API to get the actual data that has been changed. (.GetMovieChanges)
|
||||
/// </summary>
|
||||
/// <remarks>the change log system to support this was changed on October 5, 2012 and will only show movies that have been edited since.</remarks>
|
||||
public SearchContainer<ChangesListItem> GetChangesMovies(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("movie", page, startDate, endDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of people ids that have been edited.
|
||||
/// By default we show the last 24 hours and only 100 items per page.
|
||||
/// The maximum number of days that can be returned in a single request is 14.
|
||||
/// You can then use the person changes API to get the actual data that has been changed.(.GetPersonChanges)
|
||||
/// </summary>
|
||||
/// <remarks>the change log system to support this was changed on October 5, 2012 and will only show people that have been edited since.</remarks>
|
||||
public SearchContainer<ChangesListItem> GetChangesPeople(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("person", page, startDate, endDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of TV show ids that have been edited.
|
||||
/// By default we show the last 24 hours and only 100 items per page.
|
||||
/// The maximum number of days that can be returned in a single request is 14.
|
||||
/// You can then use the TV changes API to get the actual data that has been changed. (.GetTvShowChanges)
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// the change log system to properly support TV was updated on May 13, 2014.
|
||||
/// You'll likely only find the edits made since then to be useful in the change log system.
|
||||
/// </remarks>
|
||||
public SearchContainer<ChangesListItem> GetChangesTv(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("tv", page, startDate, endDate);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,90 +6,134 @@ using TMDbLib.Objects.General;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[TestClass]
|
||||
public class ClientChangesTests
|
||||
{
|
||||
private TestConfig _config;
|
||||
[TestClass]
|
||||
public class ClientChangesTests
|
||||
{
|
||||
private TestConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public void Initiator()
|
||||
{
|
||||
_config = new TestConfig();
|
||||
}
|
||||
/// <summary>
|
||||
/// Run once, on every test
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public void Initiator()
|
||||
{
|
||||
_config = new TestConfig();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestChangesMovies()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMovies();
|
||||
[TestMethod]
|
||||
public void TestChangesMovies()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMovies();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesMovies(2);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesMovies(2);
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesMovies(endDate: higher);
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesMovies(endDate: higher);
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesMovies(startDate: lower);
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesMovies(startDate: lower);
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
}
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestChangesPeople()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeople();
|
||||
[TestMethod]
|
||||
public void TestChangesPeople()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeople();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesPeople(2);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesPeople(2);
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesPeople(endDate: higher);
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesPeople(endDate: higher);
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesPeople(startDate: lower);
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesPeople(startDate: lower);
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
Assert.IsTrue(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.IsTrue(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
}
|
||||
}
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
Assert.IsTrue(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.IsTrue(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestChangesTvShows()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesTv();
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsNotNull(changesPage1.Results);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
Assert.IsTrue(changesPage1.TotalResults >= changesPage1.Results.Count);
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
|
||||
if (changesPage1.TotalPages > 1)
|
||||
{
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesTv(2);
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
}
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesTv(endDate: higher);
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesTv(startDate: lower);
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
Assert.AreNotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
Assert.IsTrue(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.IsTrue(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user