Initial Notification Support, XBMC and PLEX still need work.

This commit is contained in:
Qstick
2017-09-22 21:59:24 -04:00
parent 56e8f5c730
commit 864549b1f3
47 changed files with 381 additions and 399 deletions
@@ -1,10 +1,10 @@
using System;
using System;
using FluentAssertions;
using FluentValidation.Results;
using NUnit.Framework;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
using NzbDrone.Core.Validation;
using NzbDrone.Test.Common;
@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.NotificationTests
TestLogger.Info("OnDownload was called");
}
public override void OnRename(Series series)
public override void OnRename(Artist artist)
{
TestLogger.Info("OnRename was called");
}
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Notifications.Synology;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.NotificationTests
@@ -13,33 +13,33 @@ namespace NzbDrone.Core.Test.NotificationTests
[TestFixture]
public class SynologyIndexerFixture : CoreTest<SynologyIndexer>
{
private Series _series;
private Artist _artist;
private DownloadMessage _upgrade;
[SetUp]
public void SetUp()
{
_series = new Series()
_artist = new Artist()
{
Path = @"C:\Test\".AsOsAgnostic()
};
_upgrade = new DownloadMessage()
{
Series = _series,
Artist = _artist,
EpisodeFile = new EpisodeFile
TrackFile = new TrackFile
{
RelativePath = "file1.S01E01E02.mkv"
},
OldFiles = new List<EpisodeFile>
OldFiles = new List<TrackFile>
{
new EpisodeFile
new TrackFile
{
RelativePath = "file1.S01E01.mkv"
},
new EpisodeFile
new TrackFile
{
RelativePath = "file1.S01E02.mkv"
}
@@ -60,10 +60,10 @@ namespace NzbDrone.Core.Test.NotificationTests
{
(Subject.Definition.Settings as SynologyIndexerSettings).UpdateLibrary = false;
Subject.OnRename(_series);
Subject.OnRename(_artist);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(_series.Path), Times.Never());
.Verify(v => v.UpdateFolder(_artist.Path), Times.Never());
}
[Test]
@@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.NotificationTests
[Test]
public void should_update_entire_series_folder_on_rename()
{
Subject.OnRename(_series);
Subject.OnRename(_artist);
Mocker.GetMock<ISynologyIndexerProxy>()
.Verify(v => v.UpdateFolder(@"C:\Test\".AsOsAgnostic()), Times.Once());
@@ -1,9 +1,9 @@
using FluentAssertions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
{
@@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
public class GetSeriesPathFixture : CoreTest<HttpApiProvider>
{
private XbmcSettings _settings;
private Series _series;
private Artist _artist;
[SetUp]
public void Setup()
@@ -27,10 +27,10 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
UpdateLibrary = true
};
_series = new Series
_artist = new Artist
{
TvdbId = 79488,
Title = "30 Rock"
ForeignArtistId = "123d45d-d154f5d-1f5d1-5df18d5",
Name = "30 Rock"
};
const string setResponseUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=SetResponseFormat(webheader;false;webfooter;false;header;<xml>;footer;</xml>;opentag;<tag>;closetag;</tag>;closefinaltag;false)";
@@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
.Setup(s => s.DownloadString(query, _settings.Username, _settings.Password))
.Returns(queryResult);
Subject.GetSeriesPath(_settings, _series)
Subject.GetSeriesPath(_settings, _artist)
.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/30 Rock/");
}
@@ -72,7 +72,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
.Returns(queryResult);
Subject.GetSeriesPath(_settings, _series)
Subject.GetSeriesPath(_settings, _artist)
.Should().BeNull();
}
@@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
.Returns(queryResult);
Subject.GetSeriesPath(_settings, _series)
Subject.GetSeriesPath(_settings, _artist)
.Should().Be("smb://xbmc:xbmc@HOMESERVER/TV/Law & Order- Special Victims Unit/");
}
}
@@ -1,9 +1,9 @@
using FizzWare.NBuilder;
using FizzWare.NBuilder;
using NUnit.Framework;
using NzbDrone.Common.Http;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
{
@@ -12,7 +12,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
{
private XbmcSettings _settings;
private string _seriesQueryUrl = "http://localhost:8080/xbmcCmds/xbmcHttp?command=QueryVideoDatabase(select path.strPath from path, tvshow, tvshowlinkpath where tvshow.c12 = 79488 and tvshowlinkpath.idShow = tvshow.idShow and tvshowlinkpath.idPath = path.idPath)";
private Series _fakeSeries;
private Artist _fakeSeries;
[SetUp]
public void Setup()
@@ -28,9 +28,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http
UpdateLibrary = true
};
_fakeSeries = Builder<Series>.CreateNew()
.With(s => s.TvdbId = 79488)
.With(s => s.Title = "30 Rock")
_fakeSeries = Builder<Artist>.CreateNew()
.With(s => s.ForeignArtistId = "79488")
.With(s => s.Name = "30 Rock")
.Build();
}
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@@ -6,16 +6,16 @@ using NUnit.Framework;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Notifications.Xbmc.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
[TestFixture]
public class GetSeriesPathFixture : CoreTest<JsonApiProvider>
{
private const int TVDB_ID = 5;
private const string MB_ID = "5";
private XbmcSettings _settings;
private Series _series;
private Artist _artist;
private List<TvShow> _xbmcSeries;
[SetUp]
@@ -28,39 +28,39 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
.All()
.With(s => s.ImdbNumber = "0")
.TheFirst(1)
.With(s => s.ImdbNumber = TVDB_ID.ToString())
.With(s => s.ImdbNumber = MB_ID.ToString())
.Build()
.ToList();
Mocker.GetMock<IXbmcJsonApiProxy>()
.Setup(s => s.GetSeries(_settings))
.Setup(s => s.GetArtist(_settings))
.Returns(_xbmcSeries);
}
private void GivenMatchingTvdbId()
{
_series = new Series
{
TvdbId = TVDB_ID,
Title = "TV Show"
_artist = new Artist
{
ForeignArtistId = MB_ID,
Name = "TV Show"
};
}
private void GivenMatchingTitle()
{
_series = new Series
_artist = new Artist
{
TvdbId = 1000,
Title = _xbmcSeries.First().Label
ForeignArtistId = "1000",
Name = _xbmcSeries.First().Label
};
}
private void GivenMatchingSeries()
{
_series = new Series
_artist = new Artist
{
TvdbId = 1000,
Title = "Does not exist"
ForeignArtistId = "1000",
Name = "Does not exist"
};
}
@@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
GivenMatchingSeries();
Subject.GetSeriesPath(_settings, _series).Should().BeNull();
Subject.GetSeriesPath(_settings, _artist).Should().BeNull();
}
[Test]
@@ -77,7 +77,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
GivenMatchingTvdbId();
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File);
}
[Test]
@@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
GivenMatchingTitle();
Subject.GetSeriesPath(_settings, _series).Should().Be(_xbmcSeries.First().File);
Subject.GetSeriesPath(_settings, _artist).Should().Be(_xbmcSeries.First().File);
}
[Test]
@@ -94,13 +94,13 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
GivenMatchingTvdbId();
_xbmcSeries.ForEach(s => s.ImdbNumber = "tt12345");
_xbmcSeries.Last().ImdbNumber = TVDB_ID.ToString();
_xbmcSeries.Last().ImdbNumber = MB_ID.ToString();
Mocker.GetMock<IXbmcJsonApiProxy>()
.Setup(s => s.GetSeries(_settings))
.Setup(s => s.GetArtist(_settings))
.Returns(_xbmcSeries);
Subject.GetSeriesPath(_settings, _series).Should().NotBeNull();
Subject.GetSeriesPath(_settings, _artist).Should().NotBeNull();
}
}
}
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
@@ -6,16 +6,16 @@ using NUnit.Framework;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Notifications.Xbmc.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
{
[TestFixture]
public class UpdateFixture : CoreTest<JsonApiProvider>
{
private const int TVDB_ID = 5;
private const string MB_ID = "5";
private XbmcSettings _settings;
private List<TvShow> _xbmcSeries;
private List<TvShow> _xbmcArtist;
[SetUp]
public void Setup()
@@ -23,15 +23,15 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
_settings = Builder<XbmcSettings>.CreateNew()
.Build();
_xbmcSeries = Builder<TvShow>.CreateListOfSize(3)
_xbmcArtist = Builder<TvShow>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.ImdbNumber = TVDB_ID.ToString())
.With(s => s.ImdbNumber = MB_ID.ToString())
.Build()
.ToList();
Mocker.GetMock<IXbmcJsonApiProxy>()
.Setup(s => s.GetSeries(_settings))
.Returns(_xbmcSeries);
.Setup(s => s.GetArtist(_settings))
.Returns(_xbmcArtist);
Mocker.GetMock<IXbmcJsonApiProxy>()
.Setup(s => s.GetActivePlayers(_settings))
@@ -41,8 +41,8 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
[Test]
public void should_update_using_series_path()
{
var series = Builder<Series>.CreateNew()
.With(s => s.TvdbId = TVDB_ID)
var series = Builder<Artist>.CreateNew()
.With(s => s.ForeignArtistId = MB_ID)
.Build();
Subject.Update(_settings, series);
@@ -54,9 +54,9 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Json
[Test]
public void should_update_all_paths_when_series_path_not_found()
{
var fakeSeries = Builder<Series>.CreateNew()
.With(s => s.TvdbId = 1000)
.With(s => s.Title = "Not 30 Rock")
var fakeSeries = Builder<Artist>.CreateNew()
.With(s => s.ForeignArtistId = "1000")
.With(s => s.Name = "Not 30 Rock")
.Build();
Subject.Update(_settings, fakeSeries);
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
@@ -7,7 +7,7 @@ using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Notifications.Xbmc;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Test.NotificationTests.Xbmc
{
@@ -19,16 +19,16 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
[SetUp]
public void Setup()
{
var series = Builder<Series>.CreateNew()
var artist = Builder<Artist>.CreateNew()
.Build();
var episodeFile = Builder<EpisodeFile>.CreateNew()
var trackFile = Builder<TrackFile>.CreateNew()
.Build();
_downloadMessage = Builder<DownloadMessage>.CreateNew()
.With(d => d.Series = series)
.With(d => d.EpisodeFile = episodeFile)
.With(d => d.OldFiles = new List<EpisodeFile>())
.With(d => d.Artist = artist)
.With(d => d.TrackFile = trackFile)
.With(d => d.OldFiles = new List<TrackFile>())
.Build();
Subject.Definition = new NotificationDefinition();
@@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test.NotificationTests.Xbmc
private void GivenOldFiles()
{
_downloadMessage.OldFiles = Builder<EpisodeFile>.CreateListOfSize(1)
_downloadMessage.OldFiles = Builder<TrackFile>.CreateListOfSize(1)
.Build()
.ToList();