Fixed 503 Http errors not marking the test as ignored.

pull/6/head
kay.one 13 years ago
parent 01775d70b3
commit 0d582f12fb

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
@ -17,7 +16,6 @@ using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Test.ProviderTests; using NzbDrone.Core.Test.ProviderTests;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test namespace NzbDrone.Core.Test
{ {
@ -88,7 +86,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void newzbin_rss_fetch() public void newzbin_rss_fetch()
{ {
Mocker.Resolve<HttpProvider>(); Mocker.Resolve<HttpProvider>();
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
Mocker.GetMock<IndexerProvider>() Mocker.GetMock<IndexerProvider>()
@ -117,7 +114,7 @@ namespace NzbDrone.Core.Test
parseResults.Should().OnlyContain(s => s.Indexer == newzbinProvider.Name); parseResults.Should().OnlyContain(s => s.Indexer == newzbinProvider.Name);
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString)); parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
ExceptionVerification.MarkInconclusive(typeof(WebException)); Mark503Inconclusive();
ExceptionVerification.IgnoreWarns(); ExceptionVerification.IgnoreWarns();
} }
@ -125,8 +122,6 @@ namespace NzbDrone.Core.Test
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)] [TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", 3, 19, QualityTypes.DVD)]
public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality) public void custome_parser_partial_success(string title, int season, int episode, QualityTypes quality)
{ {
const string summary = "My fake summary"; const string summary = "My fake summary";
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
@ -152,8 +147,6 @@ namespace NzbDrone.Core.Test
[TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")] [TestCase("Adventure.Inc.DVDRip.XviD-OSiTV")]
public void custome_parser_full_parse(string title) public void custome_parser_full_parse(string title)
{ {
const string summary = "My fake summary"; const string summary = "My fake summary";
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
@ -176,7 +169,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void downloadFeed() public void downloadFeed()
{ {
Mocker.SetConstant(new HttpProvider()); Mocker.SetConstant(new HttpProvider());
var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build(); var fakeSettings = Builder<IndexerDefinition>.CreateNew().Build();
@ -206,7 +198,7 @@ namespace NzbDrone.Core.Test
var result = Mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode); var result = Mocker.Resolve<NzbsOrg>().FetchEpisode(title, season, episode);
ExceptionVerification.MarkInconclusive(typeof(WebException)); Mark503Inconclusive();
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.SeasonNumber == season);
@ -220,8 +212,6 @@ namespace NzbDrone.Core.Test
[TestCase("In plain Sight", 1, 11, Ignore = true)] [TestCase("In plain Sight", 1, 11, Ignore = true)]
public void newzbin_search_returns_valid_results(string title, int season, int episode) public void newzbin_search_returns_valid_results(string title, int season, int episode)
{ {
Mocker.GetMock<ConfigProvider>() Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NewzbinUsername) .SetupGet(c => c.NewzbinUsername)
.Returns("nzbdrone"); .Returns("nzbdrone");
@ -234,21 +224,16 @@ namespace NzbDrone.Core.Test
var result = Mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode); var result = Mocker.Resolve<Newzbin>().FetchEpisode(title, season, episode);
ExceptionVerification.MarkInconclusive(typeof(WebException)); Mark503Inconclusive();
ExceptionVerification.IgnoreWarns();
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title)); result.Should().OnlyContain(r => r.CleanTitle == Parser.NormalizeTitle(title));
result.Should().OnlyContain(r => r.SeasonNumber == season); result.Should().OnlyContain(r => r.SeasonNumber == season);
result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode)); result.Should().OnlyContain(r => r.EpisodeNumbers.Contains(episode));
} }
[Test] [Test]
public void nzbmatrix_search_returns_valid_results() public void nzbmatrix_search_returns_valid_results()
{ {
Mocker.GetMock<ConfigProvider>() Mocker.GetMock<ConfigProvider>()
.SetupGet(c => c.NzbMatrixUsername) .SetupGet(c => c.NzbMatrixUsername)
.Returns(""); .Returns("");
@ -261,7 +246,7 @@ namespace NzbDrone.Core.Test
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Simpsons", 21, 23); var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Simpsons", 21, 23);
ExceptionVerification.MarkInconclusive(typeof(WebException)); Mark503Inconclusive();
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
result.Should().OnlyContain(r => r.CleanTitle == "simpsons"); result.Should().OnlyContain(r => r.CleanTitle == "simpsons");
@ -287,7 +272,7 @@ namespace NzbDrone.Core.Test
var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19); var result = Mocker.Resolve<NzbMatrix>().FetchEpisode("Blue Bloods", 1, 19);
ExceptionVerification.MarkInconclusive(typeof(WebException)); Mark503Inconclusive();
result.Should().NotBeEmpty(); result.Should().NotBeEmpty();
result.Should().OnlyContain(r => r.CleanTitle == "bluebloods"); result.Should().OnlyContain(r => r.CleanTitle == "bluebloods");
@ -309,9 +294,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void size_newzbin() public void size_newzbin()
{ {
//Setup
Mocker.GetMock<HttpProvider>() Mocker.GetMock<HttpProvider>()
.Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>())) .Setup(h => h.DownloadStream(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
.Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml")); .Returns(File.OpenRead(".\\Files\\Rss\\SizeParsing\\newzbin.xml"));
@ -401,10 +383,10 @@ namespace NzbDrone.Core.Test
ExceptionVerification.ExpectedWarns(0); ExceptionVerification.ExpectedWarns(0);
} }
[TearDown] private static void Mark503Inconclusive()
public void TearDown()
{ {
ExceptionVerification.MarkInconclusive(typeof(WebException)); ExceptionVerification.MarkInconclusive(typeof(WebException));
ExceptionVerification.MarkInconclusive("The remote server returned an error: (503) Server Unavailable.");
} }
} }
} }

@ -86,6 +86,17 @@ namespace NzbDrone.Test.Common
} }
} }
public static void MarkInconclusive(string text)
{
var inconclusiveLogs = _logs.Where(l => l.Message.Contains(text)).ToList();
if (inconclusiveLogs.Count != 0)
{
inconclusiveLogs.ForEach(c => _logs.Remove(c));
Assert.Inconclusive(GetLogsString(inconclusiveLogs));
}
}
private static void Excpected(LogLevel level, int count) private static void Excpected(LogLevel level, int count)
{ {
var levelLogs = _logs.Where(l => l.Level == level).ToList(); var levelLogs = _logs.Where(l => l.Level == level).ToList();

Loading…
Cancel
Save