diff options
Diffstat (limited to 'tests/helper')
| -rw-r--r-- | tests/helper/PluginTester.py | 5 | ||||
| -rw-r--r-- | tests/helper/Stubs.py | 11 | ||||
| -rw-r--r-- | tests/helper/parser.py | 22 | 
3 files changed, 31 insertions, 7 deletions
| diff --git a/tests/helper/PluginTester.py b/tests/helper/PluginTester.py index 9312eb7bf..2bfb16af7 100644 --- a/tests/helper/PluginTester.py +++ b/tests/helper/PluginTester.py @@ -16,7 +16,8 @@ from json import loads  from Stubs import Thread, Core, noop  from pyload.network.RequestFactory import getRequest, getURL -from pyload.plugins.Hoster import Hoster, Abort, Fail +from pyload.plugins.Base import Abort, Fail +from pyload.plugins.Hoster import Hoster  def _wait(self):      """ waits the time previously set """ @@ -106,8 +107,6 @@ def respond(ticket, value):      finally:          f.close() - -  def invalidCaptcha(self):      log(DEBUG, "Captcha invalid")      if self.cTask: diff --git a/tests/helper/Stubs.py b/tests/helper/Stubs.py index 2c356ba3e..551778828 100644 --- a/tests/helper/Stubs.py +++ b/tests/helper/Stubs.py @@ -27,8 +27,10 @@ from logging import log, DEBUG, INFO, WARN, ERROR  def noop(*args, **kwargs):      pass +  ConfigParser.save = noop +  class LogStub:      def debug(self, *args):          log(DEBUG, *args) @@ -72,7 +74,7 @@ class Core:          self.accountManager = AccountManager()          self.addonManager = AddonManager()          self.eventManager = self.evm = NoopClass() -        self.interActionManager = self.im = NoopClass() +        self.interactionManager = self.im = NoopClass()          self.js = JsEngine()          self.cache = {}          self.packageCache = {} @@ -87,7 +89,7 @@ class Core:      def path(self, path):          return path -    def updateLink(self, *args): +    def updateFile(self, *args):          pass      def updatePackage(self, *args): @@ -96,8 +98,8 @@ class Core:      def processingIds(self, *args):          return [] -    def getPackage(self, id): -        return PyPackage(self, 0, "tmp", "tmp", "", "", 0, 0) +    def getPackage(self, *args): +        return PyPackage(self, 0, "tmp", "tmp", -1, 0, "", "", "", 0, "", 0, 0, 0)      def print_exc(self):          log(ERROR, format_exc()) @@ -132,6 +134,7 @@ class Thread(BaseThread):          return dump +  __builtin__._ = lambda x: x  __builtin__.pypath = abspath(join(dirname(__file__), "..", ".."))  __builtin__.addonManager = AddonManager() diff --git a/tests/helper/parser.py b/tests/helper/parser.py new file mode 100644 index 000000000..5031ca7c3 --- /dev/null +++ b/tests/helper/parser.py @@ -0,0 +1,22 @@ + +import codecs + +def parse_config(path): +    f = codecs.open(path, "rb", "utf_8") +    result = {} + +    current_section = None +    for line in f.readlines(): +        line = line.strip() +        if not line or line.startswith("#"): +            continue + +        if line.startswith("["): +            current_section = line.replace("[", "").replace("]", "") +            result[current_section] = [] +        else: +            if not current_section: +                raise Exception("Line without section: %s" % line) +            result[current_section].append(line) + +    return result | 
