1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 12:32:31 +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 @@ public void parse_daily_episodes(string postTitle, string title, int year, int m
[Test] [Test]
public void parse_daily_should_fail_if_episode_is_far_in_future() 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(); Parser.ParseTitle(title).Should().BeNull();

File diff suppressed because it is too large Load Diff

View File

@ -290,16 +290,12 @@ public void GetEpisodeParseResult_should_return_single_episode_when_air_date_is_
public void GetEpisodeParseResult_get_daily_should_add_new_episode() public void GetEpisodeParseResult_get_daily_should_add_new_episode()
{ {
//Setup //Setup
WithRealDb();
var fakeSeries = Builder<Series>.CreateNew() var fakeSeries = Builder<Series>.CreateNew()
.With(s => s.SeriesId = 1) .With(s => s.SeriesId = 1)
.Build(); .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 //Act
var episodes = Mocker.Resolve<EpisodeProvider>() var episodes = Mocker.Resolve<EpisodeProvider>()
.GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeSeries }, true); .GetEpisodesByParseResult(new EpisodeParseResult { AirDate = DateTime.Today, Series = fakeSeries }, true);
@ -308,7 +304,9 @@ public void GetEpisodeParseResult_get_daily_should_add_new_episode()
episodes.Should().HaveCount(1); episodes.Should().HaveCount(1);
episodes.First().AirDate.Should().Be(DateTime.Today); 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 @@ public void TearDown()
Mocker.Resolve<JobProvider>().Queue.Should().BeEmpty(); 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() private void WaitForQueue()
{ {
Console.WriteLine("Waiting for queue to clear."); Console.WriteLine("Waiting for queue to clear.");
@ -58,13 +71,12 @@ public void running_scheduled_jobs_should_updates_last_execution_time()
Mocker.SetConstant(BaseFakeJobs); Mocker.SetConstant(BaseFakeJobs);
//Act //Act
var jobProvider = Mocker.Resolve<JobProvider>(); ResetLastExecution();
jobProvider.Initialize(); Mocker.Resolve<JobProvider>().QueueScheduled();
jobProvider.QueueScheduled(); WaitForQueue();
//Assert //Assert
WaitForQueue(); var settings = Mocker.Resolve<JobProvider>().All();
var settings = jobProvider.All();
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10)); settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
fakeJob.ExecutionCount.Should().Be(1); fakeJob.ExecutionCount.Should().Be(1);
} }
@ -76,13 +88,12 @@ public void failing_scheduled_job_should_mark_job_as_failed()
Mocker.SetConstant(BaseFakeJobs); Mocker.SetConstant(BaseFakeJobs);
//Act //Act
var jobProvider = Mocker.Resolve<JobProvider>(); ResetLastExecution();
jobProvider.Initialize(); Mocker.Resolve<JobProvider>().QueueScheduled();
jobProvider.QueueScheduled(); WaitForQueue();
//Assert //Assert
WaitForQueue(); var settings = Mocker.Resolve<JobProvider>().All();
var settings = jobProvider.All();
settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10)); settings.First().LastExecution.Should().BeWithin(TimeSpan.FromSeconds(10));
settings.First().Success.Should().BeFalse(); settings.First().Success.Should().BeFalse();
brokenJob.ExecutionCount.Should().Be(1); brokenJob.ExecutionCount.Should().Be(1);
@ -96,11 +107,12 @@ public void scheduler_skips_jobs_that_arent_mature_yet()
Mocker.SetConstant(BaseFakeJobs); Mocker.SetConstant(BaseFakeJobs);
//Act //Act
var jobProvider = Mocker.Resolve<JobProvider>(); ResetLastExecution();
jobProvider.Initialize();
jobProvider.QueueScheduled(); Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue(); WaitForQueue();
jobProvider.QueueScheduled();
Mocker.Resolve<JobProvider>().QueueScheduled();
WaitForQueue(); WaitForQueue();
//Assert //Assert
@ -239,7 +251,9 @@ public void Init_Jobs()
timers[0].Interval.Should().Be(fakeJob.DefaultInterval); timers[0].Interval.Should().Be(fakeJob.DefaultInterval);
timers[0].Name.Should().Be(fakeJob.Name); timers[0].Name.Should().Be(fakeJob.Name);
timers[0].TypeName.Should().Be(fakeJob.GetType().ToString()); 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(); timers[0].Enable.Should().BeTrue();
} }
@ -325,6 +339,7 @@ public void job_with_specific_target_should_not_update_last_execution()
//Act //Act
var jobProvider = Mocker.Resolve<JobProvider>(); var jobProvider = Mocker.Resolve<JobProvider>();
jobProvider.Initialize(); jobProvider.Initialize();
ResetLastExecution();
jobProvider.QueueJob(typeof(FakeJob), 10); jobProvider.QueueJob(typeof(FakeJob), 10);
WaitForQueue(); WaitForQueue();
@ -384,15 +399,13 @@ public void Item_added_to_queue_while_scheduler_runs_should_be_executed()
IList<IJob> BaseFakeJobs = new List<IJob> { slowJob, disabledJob }; IList<IJob> BaseFakeJobs = new List<IJob> { slowJob, disabledJob };
Mocker.SetConstant(BaseFakeJobs); Mocker.SetConstant(BaseFakeJobs);
var jobProvider = Mocker.Resolve<JobProvider>(); ResetLastExecution();
jobProvider.Initialize(); var _jobThread = new Thread(Mocker.Resolve<JobProvider>().QueueScheduled);
var _jobThread = new Thread(jobProvider.QueueScheduled);
_jobThread.Start(); _jobThread.Start();
Thread.Sleep(200); Thread.Sleep(200);
jobProvider.QueueJob(typeof(DisabledJob), 12); Mocker.Resolve<JobProvider>().QueueJob(typeof(DisabledJob), 12);
WaitForQueue(); WaitForQueue();

View File

@ -278,12 +278,13 @@ public virtual void RefreshEpisodeInfo(Series series)
episodeToUpdate = new Episode(); episodeToUpdate = new Episode();
newList.Add(episodeToUpdate); 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 it is Episode Zero Ignore it, since it is new
if (episode.EpisodeNumber == 0) if (episode.EpisodeNumber == 0)
episodeToUpdate.Ignored = true; 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 else
@ -436,7 +437,7 @@ public virtual void DeleteInvalidEpisodes(Series series, TvdbSeries tvDbSeriesIn
var tvDbIdQuery = String.Format("DELETE FROM Episodes WHERE SeriesId = {0} AND TvDbEpisodeId > 0 AND TvDbEpisodeId NOT IN ({1})", var tvDbIdQuery = String.Format("DELETE FROM Episodes WHERE SeriesId = {0} AND TvDbEpisodeId > 0 AND TvDbEpisodeId NOT IN ({1})",
series.SeriesId, tvDbIdString); 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); _database.Execute(tvDbIdQuery);
Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId); Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId);

View File

@ -90,7 +90,7 @@ public virtual void Initialize()
TypeName = timer.GetType().ToString(), TypeName = timer.GetType().ToString(),
Name = timerProviderLocal.Name, Name = timerProviderLocal.Name,
Interval = timerProviderLocal.DefaultInterval, Interval = timerProviderLocal.DefaultInterval,
LastExecution = new DateTime(2000, 1, 1) LastExecution = DateTime.Now
}; };
SaveDefinition(settings); SaveDefinition(settings);

View File

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

View File

@ -7,26 +7,6 @@
.indexerPanel .indexerPanel
{ {
overflow: auto; 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> </style>
} }

View File

@ -7,9 +7,6 @@
<style> <style>
.notifier .notifier
{ {
width: 560px;
padding: 5px;
margin-left: -8px;
overflow: auto; overflow: auto;
} }
@ -21,19 +18,17 @@
padding-top: 3px; padding-top: 3px;
} }
.notifierLine
{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #CCCCCD;
padding-bottom:10px;
}
#save_button #save_button
{ {
margin-top: 10px; margin-top: 10px;
} }
#smtpTest
{
margin-top: 10px;
margin-bottom: 10px;
margin-left: 220px;
}
</style> </style>
} }
@ -48,30 +43,22 @@
@section MainContent{ @section MainContent{
<div id="stylized"> <div id="stylized">
@using (Html.BeginForm("SaveNotifications", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" })) @using (Html.BeginForm("SaveNotifications", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" }))
{ {
<div id="tabs"> <div id="accordion">
<ul> <h3><a href="#">XBMC</a></h3>
<li><a href="#tabs-xbmc">XBMC</a></li> @{Html.RenderPartial("Xbmc", Model);}
<li><a href="#tabs-smtp">SMTP</a></li>
<li><a href="#tabs-twitter">Twitter</a></li> <h3><a href="#">SMTP</a></h3>
<li><a href="#tabs-growl">Growl</a></li> @{Html.RenderPartial("Smtp", Model);}
<li><a href="#tabs-prowl">Prowl</a></li>
</ul> <h3><a href="#">Twitter</a></h3>
<div id="tabs-xbmc"> @{Html.RenderPartial("Twitter", Model);}
@{Html.RenderPartial("Xbmc", Model);}
</div> <h3><a href="#">Growl</a></h3>
<div id="tabs-smtp"> @{Html.RenderPartial("Growl", Model);}
@{Html.RenderPartial("Smtp", Model);}
</div> <h3><a href="#">Prowl</a></h3>
<div id="tabs-twitter"> @{Html.RenderPartial("Prowl", Model);}
@{Html.RenderPartial("Twitter", Model);}
</div>
<div id="tabs-growl">
@{Html.RenderPartial("Growl", Model);}
</div>
<div id="tabs-prowl">
@{Html.RenderPartial("Prowl", Model);}
</div>
</div> </div>
<button type="submit" id="save_button" disabled="disabled">Save</button> <button type="submit" id="save_button" disabled="disabled">Save</button>
@ -84,7 +71,76 @@
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(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> <span class="small">@Html.DescriptionFor(m => m.SmtpToAddresses)</span>
</label> </label>
@Html.TextBoxFor(m => m.SmtpToAddresses, new { @class = "inputClass" }) @Html.TextBoxFor(m => m.SmtpToAddresses, new { @class = "inputClass" })
</div>
<input type="button" onclick="testSmtpSettings();" value="Test SMTP" id="smtpTest"/> <input type="button" onclick="testSmtpSettings();" value="Test SMTP" id="smtpTest"/>
</div>
@*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>

View File

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

View File

@ -37,40 +37,4 @@
<input type="button" onclick="verifyTwitterAuthorization();" value="Test Authorization" class="inputClass"/> <input type="button" onclick="verifyTwitterAuthorization();" value="Test Authorization" class="inputClass"/>
@Html.Hidden("authorizationRequestToken") @Html.Hidden("authorizationRequestToken")
</div> </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>