Episode is now marked as grabbed on download

pull/2/head
kay.one 14 years ago
parent f2b091dcd2
commit c37544d4ce

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Test
public class DownloadProviderTest : TestBase
{
[Test]
public void Download_report_should_send_to_sab_and_add_to_history()
public void Download_report_should_send_to_sab_add_to_history_mark_as_grabbed()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var parseResult = Builder<EpisodeParseResult>.CreateNew()
@ -52,6 +52,13 @@ namespace NzbDrone.Core.Test
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(episodes);
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(12));
mocker.GetMock<EpisodeProvider>()
.Setup(c => c.MarkEpisodeAsFetched(99));
mocker.Resolve<DownloadProvider>().DownloadReport(parseResult);
mocker.VerifyAllMocks();

@ -757,6 +757,31 @@ namespace NzbDrone.Core.Test
episode.EpisodeFile.Should().BeNull();
}
[Test]
public void MarkEpisodeAsFetched()
{
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
.WhereAll().Have(e => e.GrabDate = null)
.Build();
db.InsertMany(fakeEpisodes);
//Act
mocker.Resolve<EpisodeProvider>().MarkEpisodeAsFetched(2);
var episodes = db.Fetch<Episode>();
//Assert
episodes.Where(e => e.EpisodeId == 2).Single().GrabDate.Should().BeWithin(TimeSpan.FromSeconds(5)).Before(
DateTime.Now);
episodes.Where(e => e.GrabDate == null).Should().HaveCount(4);
}
}

@ -185,7 +185,7 @@ namespace NzbDrone.Core.Test
}
[TestCase("simpsons", 21, 23)]
[TestCase("Hawaii Five-0 (2010)", 1, 5)]
[TestCase("Hawaii Five-0 (2010)", 1, 1)]
public void newzbin_search_returns_valid_results(string title, int season, int episode)
{
var mocker = new AutoMoqer();

@ -300,7 +300,6 @@ namespace NzbDrone.Core
return result;
}
Logger.Trace("Quality Parsed:{0} Title:", result, name);
return result;
}

@ -51,6 +51,7 @@ namespace NzbDrone.Core.Providers
history.SeriesId = episode.SeriesId;
_historyProvider.Add(history);
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);
}
}

@ -106,6 +106,13 @@ namespace NzbDrone.Core.Providers
}
public virtual void MarkEpisodeAsFetched(int episodeId)
{
Logger.Trace("Marking episode {0} as fetched.", episodeId);
_database.Execute("UPDATE Episodes SET GrabDate=@0 WHERE EpisodeId=@1", DateTime.Now, episodeId);
}
public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult, Boolean autoAddNew = false)
{
var result = new List<Episode>();

@ -61,7 +61,6 @@ namespace NzbDrone.Core.Providers.Indexer
/// <param name="episodeNumber">The episode number.</param>
/// <returns></returns>
protected abstract IList<String> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
public abstract IList<String> GetSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber);
/// <summary>
/// This method can be overwritten to provide indexer specific info parsing

@ -110,7 +110,7 @@ namespace NzbDrone.Core.Providers
{
if (currentQuality.QualityType >= cutOff)
{
Logger.Trace("Existing file meets cut-off. skipping.");
Logger.Trace("Existing item meets cut-off. skipping.");
return false;
}

Loading…
Cancel
Save