1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 18:28:19 +00:00

Fixed SAB getting the string value for Priority (instead of the integer value).

Fixed SAB tests.
Icarus appears to be deleting files from Debug\Files when running tests.
This commit is contained in:
Mark McDowall 2011-05-02 08:40:21 -07:00
parent 86019a2597
commit 0f170e8a03
2 changed files with 31 additions and 26 deletions

View file

@ -25,26 +25,26 @@ namespace NzbDrone.Core.Test
string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin"; string username = "admin";
string password = "pass"; string password = "pass";
string priority = "0"; string priority = "Normal";
string category = "tv"; string category = "tv";
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>(); var fakeConfig = mocker.GetMock<ConfigProvider>();
fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)) fakeConfig.Setup(c => c.SabHost)
.Returns(sabHost); .Returns(sabHost);
fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)) fakeConfig.Setup(c => c.SabPort)
.Returns(sabPort); .Returns(sabPort);
fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)) fakeConfig.Setup(c => c.SabApiKey)
.Returns(apikey); .Returns(apikey);
fakeConfig.Setup(c => c.GetValue("SabUsername", String.Empty, false)) fakeConfig.Setup(c => c.SabUsername)
.Returns(username); .Returns(username);
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)) fakeConfig.Setup(c => c.SabPassword)
.Returns(password); .Returns(password);
fakeConfig.Setup(c => c.GetValue("SabTvPriority", String.Empty, false)) fakeConfig.Setup(c => c.SabTvPriority)
.Returns(priority); .Returns(priority);
fakeConfig.Setup(c => c.GetValue("SabTvCategory", String.Empty, true)) fakeConfig.Setup(c => c.SabTvCategory)
.Returns(category); .Returns(category);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
@ -71,19 +71,26 @@ namespace NzbDrone.Core.Test
string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string apikey = "5c770e3197e4fe763423ee7c392c25d1";
string username = "admin"; string username = "admin";
string password = "pass"; string password = "pass";
string priority = "0"; string priority = "Normal";
string category = "tv"; string category = "tv";
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
var fakeConfig = mocker.GetMock<ConfigProvider>(); var fakeConfig = mocker.GetMock<ConfigProvider>();
fakeConfig.Setup(c => c.GetValue("SabHost", String.Empty, false)).Returns(sabHost); fakeConfig.Setup(c => c.SabHost)
fakeConfig.Setup(c => c.GetValue("SabPort", String.Empty, false)).Returns(sabPort); .Returns(sabHost);
fakeConfig.Setup(c => c.GetValue("SabApiKey", String.Empty, false)).Returns(apikey); fakeConfig.Setup(c => c.SabPort)
fakeConfig.Setup(c => c.GetValue("SabUsername", String.Empty, false)).Returns(username); .Returns(sabPort);
fakeConfig.Setup(c => c.GetValue("SabPassword", String.Empty, false)).Returns(password); fakeConfig.Setup(c => c.SabApiKey)
fakeConfig.Setup(c => c.GetValue("SabTvPriority", String.Empty, false)).Returns(priority); .Returns(apikey);
fakeConfig.Setup(c => c.GetValue("SabTvCategory", String.Empty, true)).Returns(category); fakeConfig.Setup(c => c.SabUsername)
.Returns(username);
fakeConfig.Setup(c => c.SabPassword)
.Returns(password);
fakeConfig.Setup(c => c.SabTvPriority)
.Returns(priority);
fakeConfig.Setup(c => c.SabTvCategory)
.Returns(category);
mocker.GetMock<HttpProvider>() mocker.GetMock<HttpProvider>()
.Setup( .Setup(

View file

@ -30,8 +30,7 @@ namespace NzbDrone.Core.Providers
{ {
const string mode = "addurl"; const string mode = "addurl";
string cat = _configProvider.SabTvCategory; string cat = _configProvider.SabTvCategory;
//string cat = "tv"; int priority = (int)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.SabTvPriority);
string priority = _configProvider.SabTvPriority;
string name = url.Replace("&", "%26"); string name = url.Replace("&", "%26");
string nzbName = HttpUtility.UrlEncode(title); string nzbName = HttpUtility.UrlEncode(title);
@ -84,9 +83,8 @@ namespace NzbDrone.Core.Providers
//mode=addid&name=333333&pp=3&script=customscript.cmd&cat=Example&priority=-1 //mode=addid&name=333333&pp=3&script=customscript.cmd&cat=Example&priority=-1
const string mode = "addid"; const string mode = "addid";
string cat = _configProvider.GetValue("SabTvCategory", String.Empty, true); string cat = _configProvider.SabTvCategory;
//string cat = "tv"; int priority = (int)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.SabTvPriority);
string priority = _configProvider.GetValue("SabTvPriority", String.Empty, false);
string nzbName = HttpUtility.UrlEncode(title); string nzbName = HttpUtility.UrlEncode(title);
string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat, string action = string.Format("mode={0}&name={1}&priority={2}&cat={3}&nzbname={4}", mode, id, priority, cat,
@ -106,11 +104,11 @@ namespace NzbDrone.Core.Providers
private string GetSabRequest(string action) private string GetSabRequest(string action)
{ {
string sabnzbdInfo = _configProvider.GetValue("SabHost", String.Empty, false) + ":" + string sabnzbdInfo = _configProvider.SabHost + ":" +
_configProvider.GetValue("SabPort", String.Empty, false); _configProvider.SabPort;
string username = _configProvider.GetValue("SabUsername", String.Empty, false); string username = _configProvider.SabUsername;
string password = _configProvider.GetValue("SabPassword", String.Empty, false); string password = _configProvider.SabPassword;
string apiKey = _configProvider.GetValue("SabApiKey", String.Empty, false); string apiKey = _configProvider.SabApiKey;
return return
string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey, string.Format(@"http://{0}/api?$Action&apikey={1}&ma_username={2}&ma_password={3}", sabnzbdInfo, apiKey,