parent
b76c6329fe
commit
beb2f7c7fd
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class EpisodeSearchJobTest:SqlCeTest
|
||||
{
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), new { EpisodeId = target });
|
||||
}
|
||||
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_secondary_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), new { SeriesId = 1, SeasonNumber = target });
|
||||
}
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFileTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanUpDatabaseFixture : SqlCeTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
}
|
||||
|
||||
private void WithAutoIgnore(bool autoIgnore)
|
||||
{
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(c => c.AutoIgnorePreviouslyDownloadedEpisodes).Returns(autoIgnore);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_auto_ignore()
|
||||
{
|
||||
WithAutoIgnore(true);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.Ignored = false)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().OnlyContain(e => e.Ignored);
|
||||
result.Should().OnlyContain(e => e.GrabDate == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_no_auto_ignore()
|
||||
{
|
||||
WithAutoIgnore(false);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.TheFirst(2).With(c => c.Ignored = true)
|
||||
.TheLast(1).With(c => c.Ignored = false)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().OnlyContain(e => e.GrabDate == null);
|
||||
result.Should().Contain(c => c.Ignored == true);
|
||||
result.Should().Contain(c => c.Ignored == false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_not_change_episodes_with_no_file_id()
|
||||
{
|
||||
//Setup
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.Ignored = false)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().NotContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().NotContain(e => e.Ignored);
|
||||
result.Should().NotContain(e => e.GrabDate == null);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DeleteOrphanedEpisodeFiles()
|
||||
{
|
||||
//Setup
|
||||
var episodeFiles = Builder<EpisodeFile>
|
||||
.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.Quality = Quality.DVD)
|
||||
.Build();
|
||||
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<EpisodeFile>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
result.Should().OnlyContain(e => e.Id > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
</configuration>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
|
||||
public interface IDailySeriesDataProxy
|
||||
{
|
||||
IEnumerable<int> GetDailySeriesIds();
|
||||
}
|
||||
|
||||
public class DailySeriesDataProxy : IDailySeriesDataProxy
|
||||
{
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DailySeriesDataProxy(HttpProvider httpProvider, IConfigService configService, Logger logger)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetDailySeriesIds()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
return seriesIds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to get Daily Series", ex);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public interface ISceneMappingProxy
|
||||
{
|
||||
List<SceneMapping> Fetch();
|
||||
}
|
||||
|
||||
public class SceneMappingProxy : ISceneMappingProxy
|
||||
{
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public SceneMappingProxy(HttpProvider httpProvider, IConfigService configService)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public List<SceneMapping> Fetch()
|
||||
{
|
||||
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
|
||||
return JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
}
|
||||
|
||||
|
||||
/* public virtual bool SubmitMapping(int id, string postTitle)
|
||||
{
|
||||
Logger.Trace("Parsing example post");
|
||||
var episodeParseResult = Parser.ParseTitle(postTitle);
|
||||
var cleanTitle = episodeParseResult.CleanTitle;
|
||||
var title = episodeParseResult.SeriesTitle.Replace('.', ' ');
|
||||
Logger.Trace("Example post parsed. CleanTitle: {0}, Title: {1}", cleanTitle, title);
|
||||
|
||||
var newMapping = String.Format("/SceneMapping/AddPending?cleanTitle={0}&id={1}&title={2}", cleanTitle, id, title);
|
||||
var response = _httpProvider.DownloadString(_configService.ServiceRootUrl + newMapping);
|
||||
|
||||
if (JsonConvert.DeserializeObject<String>(response).Equals("Ok"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public interface ISceneMappingRepository : IBasicRepository<SceneMapping>
|
||||
{
|
||||
SceneMapping FindByTvdbId(int tvdbId);
|
||||
SceneMapping FindByCleanTitle(string cleanTitle);
|
||||
|
||||
}
|
||||
|
||||
public class SceneMappingRepository : BasicRepository<SceneMapping>, ISceneMappingRepository
|
||||
{
|
||||
public SceneMappingRepository(IObjectDatabase objectDatabase)
|
||||
: base(objectDatabase)
|
||||
{
|
||||
}
|
||||
|
||||
public SceneMapping FindByTvdbId(int tvdbId)
|
||||
{
|
||||
return Queryable.SingleOrDefault(c => c.TvdbId == tvdbId);
|
||||
}
|
||||
|
||||
public SceneMapping FindByCleanTitle(string cleanTitle)
|
||||
{
|
||||
return Queryable.SingleOrDefault(c => c.CleanTitle == cleanTitle);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue