Browse Source

Always use Default-priority when creating NZB-objects

Closes #1552
tags/3.0.0RC2
Safihre 5 years ago
parent
commit
b670da9fa0
  1. 4
      sabnzbd/__init__.py
  2. 3
      sabnzbd/nzbqueue.py
  3. 2
      sabnzbd/nzbstuff.py
  4. 4
      sabnzbd/rss.py
  5. 26
      tests/test_misc.py

4
sabnzbd/__init__.py

@ -105,7 +105,7 @@ import sabnzbd.nzbstuff as nzbstuff
import sabnzbd.directunpacker as directunpacker
from sabnzbd.decorators import synchronized
from sabnzbd.constants import (
NORMAL_PRIORITY,
DEFAULT_PRIORITY,
VALID_ARCHIVES,
REPAIR_REQUEST,
QUEUE_FILE_NAME,
@ -646,7 +646,7 @@ def add_nzbfile(
script=None,
cat=None,
catdir=None,
priority=NORMAL_PRIORITY,
priority=DEFAULT_PRIORITY,
nzbname=None,
nzo_info=None,
url=None,

3
sabnzbd/nzbqueue.py

@ -38,6 +38,7 @@ from sabnzbd.constants import (
QUEUE_VERSION,
FUTURE_Q_FOLDER,
JOB_ADMIN,
DEFAULT_PRIORITY,
LOW_PRIORITY,
NORMAL_PRIORITY,
HIGH_PRIORITY,
@ -240,7 +241,7 @@ class NzbQueue:
def set_top_only(self, value):
self.__top_only = value
def generate_future(self, msg, pp=None, script=None, cat=None, url=None, priority=NORMAL_PRIORITY, nzbname=None):
def generate_future(self, msg, pp=None, script=None, cat=None, url=None, priority=DEFAULT_PRIORITY, nzbname=None):
""" Create and return a placeholder nzo object """
logging.debug("Creating placeholder NZO")
future_nzo = NzbObject(

2
sabnzbd/nzbstuff.py

@ -569,7 +569,7 @@ class NzbObject(TryList):
futuretype=False,
cat=None,
url=None,
priority=NORMAL_PRIORITY,
priority=DEFAULT_PRIORITY,
nzbname=None,
status=Status.QUEUED,
nzo_info=None,

4
sabnzbd/rss.py

@ -26,7 +26,7 @@ import datetime
import threading
import sabnzbd
from sabnzbd.constants import RSS_FILE_NAME, DEFAULT_PRIORITY, NORMAL_PRIORITY, DUP_PRIORITY
from sabnzbd.constants import RSS_FILE_NAME, DEFAULT_PRIORITY, DUP_PRIORITY
from sabnzbd.decorators import synchronized
import sabnzbd.config as config
import sabnzbd.cfg as cfg
@ -685,7 +685,7 @@ def _HandleLink(
script,
download,
star,
priority=NORMAL_PRIORITY,
priority=DEFAULT_PRIORITY,
rule=0,
):
""" Process one link """

26
tests/test_misc.py

@ -24,6 +24,7 @@ import datetime
from sabnzbd import lang
from sabnzbd import misc
from sabnzbd.config import ConfigCat
from sabnzbd.constants import HIGH_PRIORITY, TOP_PRIORITY, DEFAULT_PRIORITY, NORMAL_PRIORITY
from tests.testhelper import *
@ -66,13 +67,26 @@ class TestMisc:
assert misc.cmp(1, 1) == 0
def test_cat_to_opts(self):
# Need to create the Default category
# Need to create the Default category, as we would in normal instance
# Otherwise it will try to save the config
ConfigCat("*", {})
assert ("*", "", "Default", -100) == misc.cat_to_opts("*")
assert ("*", "", "Default", -100) == misc.cat_to_opts("Nonsense")
assert ("*", 1, "Default", -100) == misc.cat_to_opts("*", pp=1)
assert ("*", 1, "test.py", -100) == misc.cat_to_opts("*", pp=1, script="test.py")
ConfigCat("*", {"pp": 3, "script": "None", "priority": NORMAL_PRIORITY})
assert ("*", 3, "None", NORMAL_PRIORITY) == misc.cat_to_opts("*")
assert ("*", 3, "None", NORMAL_PRIORITY) == misc.cat_to_opts("Nonsense")
assert ("*", 1, "None", NORMAL_PRIORITY) == misc.cat_to_opts("*", pp=1)
assert ("*", 1, "test.py", NORMAL_PRIORITY) == misc.cat_to_opts("*", pp=1, script="test.py")
ConfigCat("movies", {"priority": HIGH_PRIORITY, "script": "test.py"})
assert ("movies", 3, "test.py", HIGH_PRIORITY) == misc.cat_to_opts("movies")
assert ("movies", 1, "test.py", HIGH_PRIORITY) == misc.cat_to_opts("movies", pp=1)
assert ("movies", 1, "not_test.py", HIGH_PRIORITY) == misc.cat_to_opts("movies", pp=1, script="not_test.py")
assert ("movies", 3, "test.py", TOP_PRIORITY) == misc.cat_to_opts("movies", priority=TOP_PRIORITY)
# If the category has DEFAULT_PRIORITY, it should use the priority of the *-category (NORMAL_PRIORITY)
# If the script-name is Default for a category, it should use the script of the *-category (None)
ConfigCat("software", {"priority": DEFAULT_PRIORITY, "script": "Default"})
assert ("software", 3, "None", NORMAL_PRIORITY) == misc.cat_to_opts("software")
assert ("software", 3, "None", TOP_PRIORITY) == misc.cat_to_opts("software", priority=TOP_PRIORITY)
def test_wildcard_to_re(self):
assert "\\\\\\^\\$\\.\\[" == misc.wildcard_to_re("\\^$.[")

Loading…
Cancel
Save