mirror of https://github.com/Radarr/Radarr
more tests and bug fixes
This commit is contained in:
parent
282870cd80
commit
e074164a47
|
@ -116,6 +116,35 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.AreEqual(excpected, result);
|
Assert.AreEqual(excpected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void get_episode_by_parse_result()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var repo = MockLib.GetEmptyRepository();
|
||||||
|
var fakeEpisodes = MockLib.GetFakeEpisodes(2);
|
||||||
|
repo.AddMany(fakeEpisodes);
|
||||||
|
mocker.SetConstant(repo);
|
||||||
|
|
||||||
|
var targetEpisode = fakeEpisodes[4];
|
||||||
|
|
||||||
|
var parseResult1 = new EpisodeParseResult
|
||||||
|
{
|
||||||
|
SeriesId = targetEpisode.SeriesId,
|
||||||
|
SeasonNumber = targetEpisode.SeasonNumber,
|
||||||
|
Episodes = new List<int> { targetEpisode.EpisodeNumber },
|
||||||
|
Quality = QualityTypes.DVD
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = mocker.Resolve<EpisodeProvider>().GetEpisodeByParseResult(parseResult1);
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Count(1, result);
|
||||||
|
Assert.AreEqual(targetEpisode.EpisodeId, result.First().EpisodeId);
|
||||||
|
Assert.AreEqual(targetEpisode.EpisodeNumber, result.First().EpisodeNumber);
|
||||||
|
Assert.AreEqual(targetEpisode.SeasonNumber, result.First().SeasonNumber);
|
||||||
|
Assert.AreEqual(targetEpisode.SeriesId, result.First().SeriesId);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Missing_episode_should_be_added()
|
public void Missing_episode_should_be_added()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using AutoMoq;
|
||||||
using MbUnit.Framework;
|
using MbUnit.Framework;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
@ -63,6 +64,30 @@ namespace NzbDrone.Core.Test
|
||||||
Assert.AreEqual(result.Count(), 1);
|
Assert.AreEqual(result.Count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void add_item()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var repo = MockLib.GetEmptyRepository();
|
||||||
|
|
||||||
|
mocker.SetConstant(repo);
|
||||||
|
|
||||||
|
var episodes = MockLib.GetFakeEpisodes(1);
|
||||||
|
repo.AddMany(episodes);
|
||||||
|
|
||||||
|
var episode = episodes[5];
|
||||||
|
|
||||||
|
var history = new History
|
||||||
|
{
|
||||||
|
Date = DateTime.Now,
|
||||||
|
EpisodeId = episode.EpisodeId,
|
||||||
|
NzbTitle = "my title"
|
||||||
|
};
|
||||||
|
|
||||||
|
mocker.Resolve<HistoryProvider>().Add(history);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public void Exists_True()
|
public void Exists_True()
|
||||||
|
|
|
@ -82,5 +82,14 @@ namespace NzbDrone.Core.Test
|
||||||
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IList<Episode> GetFakeEpisodes(int seriesId)
|
||||||
|
{
|
||||||
|
var epNumber = new SequentialGenerator<int>();
|
||||||
|
return Builder<Episode>.CreateListOfSize(10)
|
||||||
|
.WhereAll().Have(c => c.SeriesId = seriesId)
|
||||||
|
.WhereAll().Have(c => c.EpisodeNumber = epNumber.Generate())
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Test
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[Row("The Test", "Test")]
|
[Row("The Test", "Test")]
|
||||||
[Row("The Test Title", "test title")]
|
[Row("Through the Wormhole", "Through.the.Wormhole")]
|
||||||
public void find_series_match(string title, string searchTitle)
|
public void find_series_match(string title, string searchTitle)
|
||||||
{
|
{
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
|
|
@ -57,10 +57,12 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual IList<Episode> GetEpisodeByParseResult(EpisodeParseResult parseResult)
|
public virtual IList<Episode> GetEpisodeByParseResult(EpisodeParseResult parseResult)
|
||||||
{
|
{
|
||||||
return _sonicRepo.Find<Episode>(e =>
|
var seasonEpisodes = _sonicRepo.All<Episode>().Where(e =>
|
||||||
e.SeriesId == parseResult.SeriesId &&
|
e.SeriesId == parseResult.SeriesId &&
|
||||||
e.SeasonNumber == parseResult.SeasonNumber &&
|
e.SeasonNumber == parseResult.SeasonNumber).ToList();
|
||||||
parseResult.Episodes.Contains(e.EpisodeNumber));
|
|
||||||
|
//Has to be done separately since subsonic doesn't support contain method
|
||||||
|
return seasonEpisodes.Where(c => parseResult.Episodes.Contains(c.EpisodeNumber)).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,10 @@ namespace NzbDrone.Core.Providers
|
||||||
Logger.Info("History has been trimmed, items older than 30 days have been removed");
|
Logger.Info("History has been trimmed, items older than 30 days have been removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Insert(History item)
|
public virtual void Add(History item)
|
||||||
{
|
{
|
||||||
_sonicRepo.Add(item);
|
_sonicRepo.Add(item);
|
||||||
Logger.Debug("Item added to history: {0} - {1}x{2:00}", item.Episode.Series.Title, item.Episode.SeasonNumber, item.Episode.EpisodeNumber);
|
Logger.Debug("Item added to history: {0}", item.NzbTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Exists(int episodeId, QualityTypes quality, bool proper)
|
public virtual bool Exists(int episodeId, QualityTypes quality, bool proper)
|
||||||
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Providers
|
||||||
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper))
|
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && h.Quality == quality && h.IsProper == proper))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Logger.Debug("Episode not in History. ID:{0} Q:{1} Proper:{2}", episodeId , quality, proper);
|
Logger.Debug("Episode not in History. ID:{0} Q:{1} Proper:{2}", episodeId, quality, proper);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,12 +68,20 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
|
|
||||||
foreach (var item in feed)
|
foreach (var item in feed)
|
||||||
{
|
{
|
||||||
ProcessItem(item);
|
try
|
||||||
|
{
|
||||||
|
ProcessItem(item);
|
||||||
|
}
|
||||||
|
catch (Exception itemEx)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("An error occurred while processing feed item", itemEx);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception feedEx)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("An error occurred while processing feed", e);
|
_logger.ErrorException("An error occurred while processing feed", feedEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +90,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
|
|
||||||
internal void ProcessItem(SyndicationItem feedItem)
|
internal void ProcessItem(SyndicationItem feedItem)
|
||||||
{
|
{
|
||||||
_logger.Info("Processing RSS feed item " + feedItem.Title.Text);
|
_logger.Debug("Processing RSS feed item " + feedItem.Title.Text);
|
||||||
|
|
||||||
var parseResult = ParseFeed(feedItem);
|
var parseResult = ParseFeed(feedItem);
|
||||||
|
|
||||||
|
@ -124,7 +132,7 @@ namespace NzbDrone.Core.Providers.Indexer
|
||||||
|
|
||||||
//TODO: Add episode to sab
|
//TODO: Add episode to sab
|
||||||
|
|
||||||
_historyProvider.Insert(new History
|
_historyProvider.Add(new History
|
||||||
{
|
{
|
||||||
Date = DateTime.Now,
|
Date = DateTime.Now,
|
||||||
EpisodeId = episode.EpisodeId,
|
EpisodeId = episode.EpisodeId,
|
||||||
|
|
Loading…
Reference in New Issue