1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-31 07:52:37 +01:00

Merge branch 'markus' into kay.one

This commit is contained in:
kay.one 2011-11-30 20:16:59 -08:00
commit 0e91aeb689
12 changed files with 413 additions and 543 deletions

View File

@ -184,7 +184,7 @@ namespace NzbDrone.Core.Test
[Test]
public void parse_daily_should_fail_if_episode_is_far_in_future()
{
var title = string.Format("{0}.{1}.{2} - Denis Leary - HD TV.mkv", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(2).Day);
var title = string.Format("{0:yyyy.MM.dd} - Denis Leary - HD TV.mkv", DateTime.Now.AddDays(2));
Parser.ParseTitle(title).Should().BeNull();

File diff suppressed because it is too large Load Diff

View File

@ -290,16 +290,12 @@ namespace NzbDrone.Core.Test.ProviderTests
public void GetEpisodeParseResult_get_daily_should_add_new_episode()
{
//Setup
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew()
.With(s => s.SeriesId = 1)
.Build();
Mocker.GetMock<IDatabase>().Setup(s => s.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
.Returns(new List<Episode>());
Mocker.GetMock<IDatabase>().Setup(s => s.Insert(It.IsAny<Episode>()))
.Returns(1);
//Act
var episodes = Mocker.Resolve<EpisodeProvider>()
.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeSeries }, true);
@ -308,7 +304,9 @@ namespace NzbDrone.Core.Test.ProviderTests
episodes.Should().HaveCount(1);
episodes.First().AirDate.Should().Be(DateTime.Today);
Mocker.GetMock<IDatabase>().Verify(v => v.Insert(It.IsAny<Episode>()), Times.Once());
var episodesInDb = Db.Fetch<Episode>();
episodesInDb.Should().HaveCount(1);
}
}
}

View File

@ -40,6 +40,19 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
Mocker.Resolve<JobProvider>().Queue.Should().BeEmpty();
}
private void ResetLastExecution()
{
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
var jobs = jobProvider.All();
foreach (var jobDefinition in jobs)
{
jobDefinition.LastExecution = new DateTime(2000, 1, 1);
jobProvider.SaveDefinition(jobDefinition);
}
}
private void WaitForQueue()
{
Console.WriteLine("Waiting for queue to clear.");
@ -58,13 +71,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
Mocker.SetConstant(BaseFakeJobs);
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueScheduled();
ResetLastExecution();
Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue();
//Assert
WaitForQueue();
var settings = jobProvider.All();
var settings = Mocker.Resolve<JobProvider>().All();
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
fakeJob.ExecutionCount.Should().Be(1);
}
@ -76,13 +88,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
Mocker.SetConstant(BaseFakeJobs);
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueScheduled();
ResetLastExecution();
Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue();
//Assert
WaitForQueue();
var settings = jobProvider.All();
var settings = Mocker.Resolve<JobProvider>().All();
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
settings.First().Success.Should().BeFalse();
brokenJob.ExecutionCount.Should().Be(1);
@ -96,11 +107,12 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
Mocker.SetConstant(BaseFakeJobs);
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
jobProvider.QueueScheduled();
ResetLastExecution();
Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue();
jobProvider.QueueScheduled();
Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue();
//Assert
@ -239,7 +251,9 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
timers[0].Interval.Should().Be(fakeJob.DefaultInterval);
timers[0].Name.Should().Be(fakeJob.Name);
timers[0].TypeName.Should().Be(fakeJob.GetType().ToString());
timers[0].LastExecution.Should().HaveYear(2000);
timers[0].LastExecution.Should().HaveYear(DateTime.Now.Year);
timers[0].LastExecution.Should().HaveMonth(DateTime.Now.Month);
timers[0].LastExecution.Should().HaveDay(DateTime.Today.Day);
timers[0].Enable.Should().BeTrue();
}
@ -325,6 +339,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
//Act
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
ResetLastExecution();
jobProvider.QueueJob(typeof(FakeJob), 10);
WaitForQueue();
@ -384,15 +399,13 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
IList<IJob> BaseFakeJobs = new List<IJob> { slowJob, disabledJob };
Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize();
var _jobThread = new Thread(jobProvider.QueueScheduled);
ResetLastExecution();
var _jobThread = new Thread(Mocker.Resolve<JobProvider>().QueueScheduled);
_jobThread.Start();
Thread.Sleep(200);
jobProvider.QueueJob(typeof(DisabledJob), 12);
Mocker.Resolve<JobProvider>().QueueJob(typeof(DisabledJob), 12);
WaitForQueue();

View File

@ -278,12 +278,13 @@ namespace NzbDrone.Core.Providers
episodeToUpdate = new Episode();
newList.Add(episodeToUpdate);
//We need to check if this episode should be ignored based on IsIgnored rules
IsIgnored(series.SeriesId, episode.SeasonNumber);
//If it is Episode Zero Ignore it, since it is new
if (episode.EpisodeNumber == 0)
episodeToUpdate.Ignored = true;
//Else we need to check if this episode should be ignored based on IsIgnored rules
else
episodeToUpdate.Ignored = IsIgnored(series.SeriesId, episode.SeasonNumber);
}
else
@ -436,7 +437,7 @@ namespace NzbDrone.Core.Providers
var tvDbIdQuery = String.Format("DELETE FROM Episodes WHERE SeriesId = {0} AND TvDbEpisodeId > 0 AND TvDbEpisodeId NOT IN ({1})",
series.SeriesId, tvDbIdString);
Logger.Trace("Deleting nivalid episodes by TvDbId for {0}", series.SeriesId);
Logger.Trace("Deleting invalid episodes by TvDbId for {0}", series.SeriesId);
_database.Execute(tvDbIdQuery);
Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId);

View File

@ -90,7 +90,7 @@ namespace NzbDrone.Core.Providers.Jobs
TypeName = timer.GetType().ToString(),
Name = timerProviderLocal.Name,
Interval = timerProviderLocal.DefaultInterval,
LastExecution = new DateTime(2000, 1, 1)
LastExecution = DateTime.Now
};
SaveDefinition(settings);

View File

@ -9,17 +9,10 @@ p, h1, form, button{border:0; margin:0; padding:0;}
.settingsForm
{
/*margin:0 auto;*/
width: 600px;
width: 620px;
padding: 14px;
}
#stylized
{
/*border:solid 2px #b7ddf2;
background:#ebf4fb;*/
}
#stylized h1
{
font-size:20px;

View File

@ -7,26 +7,6 @@
.indexerPanel
{
overflow: auto;
padding-top: 20px;
}
.additionalInfo
{
float: right;
margin-top: 20px;
margin-right: 40px;
font-size: 120%;
font-weight: bold;
}
#stylized .indexerPanel .labelClass
{
width: 320px;
}
#stylized .indexerPanel .small
{
width: 320px;
}
</style>
}

View File

@ -7,9 +7,6 @@
<style>
.notifier
{
width: 560px;
padding: 5px;
margin-left: -8px;
overflow: auto;
}
@ -21,19 +18,17 @@
padding-top: 3px;
}
.notifierLine
{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #CCCCCD;
padding-bottom:10px;
}
#save_button
{
margin-top: 10px;
}
#smtpTest
{
margin-top: 10px;
margin-bottom: 10px;
margin-left: 220px;
}
</style>
}
@ -48,30 +43,22 @@
@section MainContent{
<div id="stylized">
@using (Html.BeginForm("SaveNotifications", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" }))
{
<div id="tabs">
<ul>
<li><a href="#tabs-xbmc">XBMC</a></li>
<li><a href="#tabs-smtp">SMTP</a></li>
<li><a href="#tabs-twitter">Twitter</a></li>
<li><a href="#tabs-growl">Growl</a></li>
<li><a href="#tabs-prowl">Prowl</a></li>
</ul>
<div id="tabs-xbmc">
@{Html.RenderPartial("Xbmc", Model);}
</div>
<div id="tabs-smtp">
@{Html.RenderPartial("Smtp", Model);}
</div>
<div id="tabs-twitter">
@{Html.RenderPartial("Twitter", Model);}
</div>
<div id="tabs-growl">
@{Html.RenderPartial("Growl", Model);}
</div>
<div id="tabs-prowl">
@{Html.RenderPartial("Prowl", Model);}
</div>
{
<div id="accordion">
<h3><a href="#">XBMC</a></h3>
@{Html.RenderPartial("Xbmc", Model);}
<h3><a href="#">SMTP</a></h3>
@{Html.RenderPartial("Smtp", Model);}
<h3><a href="#">Twitter</a></h3>
@{Html.RenderPartial("Twitter", Model);}
<h3><a href="#">Growl</a></h3>
@{Html.RenderPartial("Growl", Model);}
<h3><a href="#">Prowl</a></h3>
@{Html.RenderPartial("Prowl", Model);}
</div>
<button type="submit" id="save_button" disabled="disabled">Save</button>
@ -84,7 +71,76 @@
<script type="text/javascript">
$(function () {
$("#tabs").tabs();
$("#accordion").accordion({
autoHeight: false
});
});
</script>
//Twitter
getAuthorizationUrl = '../Command/GetTwitterAuthorization';
verifyAuthorizationUrl = '../Command/VerifyTwitterAuthorization';
function requestTwitterAuthorization() {
$.ajax({
type: "GET",
url: getAuthorizationUrl,
error: function(req, status, error) {
alert("Sorry! We could get Twitter Authorization at this time. " + error);
},
success: function(data, textStatus, jqXHR) {
if (data.IsMessage)
return false;
$('#authorizationRequestToken').val(data.Token);
window.open(data.Url);
}
});
}
function verifyTwitterAuthorization() {
var token = $('#authorizationRequestToken').val();
var verifier = $('#twitterVerification').val();
$.ajax({
type: "GET",
url: verifyAuthorizationUrl,
data: jQuery.param({ token: token, verifier: verifier }),
error: function(req, status, error) {
alert("Sorry! We could verify Twitter Authorization at this time. " + error);
}
});
}
//SMTP
function testSmtpSettings() {
//Get the variables
var server = $('#SmtpServer').val();
var port = $('#SmtpPort').val();
var ssl = $('#SmtpUseSsl').val();
var username = $('#SmtpUsername').val();
var password = $('#SmtpPassword').val();
var fromAddress = $('#SmtpFromAddress').val();
var toAddresses = $('#SmtpToAddresses').val();
//Send the data!
$.ajax({
type: "POST",
url: '../Command/SendTestEmail',
data: jQuery.param({
server: server,
port: port,
ssl: ssl,
username: username,
password: password,
fromAddress: fromAddress,
toAddresses: toAddresses
}),
error: function (req, status, error) {
alert("Sorry! We could send a test email at this time. " + error);
}
});
return false;
}
</script>
}

View File

@ -55,49 +55,6 @@
<span class="small">@Html.DescriptionFor(m => m.SmtpToAddresses)</span>
</label>
@Html.TextBoxFor(m => m.SmtpToAddresses, new { @class = "inputClass" })
</div>
<input type="button" onclick="testSmtpSettings();" value="Test SMTP" id="smtpTest"/>
@*Move this somewhere better*@
<style>
#smtpTest
{
margin-top: 10px;
margin-bottom: 10px;
margin-left: 220px;
}
</style>
<script type="text/javascript">
function testSmtpSettings() {
//Get the variables
var server = $('#SmtpServer').val();
var port = $('#SmtpPort').val();
var ssl = $('#SmtpUseSsl').val();
var username = $('#SmtpUsername').val();
var password = $('#SmtpPassword').val();
var fromAddress = $('#SmtpFromAddress').val();
var toAddresses = $('#SmtpToAddresses').val();
//Send the data!
$.ajax({
type: "POST",
url: '../Command/SendTestEmail',
data: jQuery.param({
server: server,
port: port,
ssl: ssl,
username: username,
password: password,
fromAddress: fromAddress,
toAddresses: toAddresses
}),
error: function (req, status, error) {
alert("Sorry! We could send a test email at this time. " + error);
}
});
return false;
}
</script>
<input type="button" onclick="testSmtpSettings();" value="Test SMTP" id="smtpTest"/>
</div>

View File

@ -1,8 +1,8 @@
<ul class="sub-menu">
<li>@Html.ActionLink("Indexers", "Indexers", "Settings")</li>
<li>@Html.ActionLink("Quality", "Quality", "Settings")</li>
<li>@Html.ActionLink("Naming", "Naming", "Settings")</li>
<li>@Html.ActionLink("Notifications", "Notifications", "Settings")</li>
<li>@Html.ActionLink("Indexers", "Indexers", "Settings")</li>
<li>@Html.ActionLink("SABnzbd", "Sabnzbd", "Settings")</li>
<li>@Html.ActionLink("System", "System", "Settings")</li>
</ul>

View File

@ -37,40 +37,4 @@
<input type="button" onclick="verifyTwitterAuthorization();" value="Test Authorization" class="inputClass"/>
@Html.Hidden("authorizationRequestToken")
</div>
<script type="text/javascript">
getAuthorizationUrl = '../Command/GetTwitterAuthorization';
verifyAuthorizationUrl = '../Command/VerifyTwitterAuthorization';
function requestTwitterAuthorization() {
$.ajax({
type: "GET",
url: getAuthorizationUrl,
error: function(req, status, error) {
alert("Sorry! We could get Twitter Authorization at this time. " + error);
},
success: function(data, textStatus, jqXHR) {
if (data.IsMessage)
return false;
$('#authorizationRequestToken').val(data.Token);
window.open(data.Url);
}
});
}
function verifyTwitterAuthorization() {
var token = $('#authorizationRequestToken').val();
var verifier = $('#twitterVerification').val();
$.ajax({
type: "GET",
url: verifyAuthorizationUrl,
data: jQuery.param({ token: token, verifier: verifier }),
error: function(req, status, error) {
alert("Sorry! We could verify Twitter Authorization at this time. " + error);
}
});
}
</script>
</div>