diff options
Diffstat (limited to 'tests/CrypterPluginTester.py')
-rw-r--r-- | tests/CrypterPluginTester.py | 71 |
1 files changed, 68 insertions, 3 deletions
diff --git a/tests/CrypterPluginTester.py b/tests/CrypterPluginTester.py index 124cb4d0a..27013ede7 100644 --- a/tests/CrypterPluginTester.py +++ b/tests/CrypterPluginTester.py @@ -1,6 +1,71 @@ # -*- coding: utf-8 -*- -from unittest import TestCase +from os.path import dirname, join +from nose.tools import nottest -class DecryptPluginTester(TestCase): - pass
\ No newline at end of file +from logging import log, DEBUG + +from helper.Stubs import Core +from helper.PluginTester import PluginTester + +from module.plugins.Base import Fail +from module.utils import accumulate, to_int + +class CrypterPluginTester(PluginTester): + + @nottest + def test_plugin(self, name, url, flag): + + log(DEBUG, "%s: %s", name, url) + + plugin = self.core.pluginManager.getPluginClass(name) + p = plugin(self.core, None, "") + self.thread.plugin = p + + try: + result = p._decrypt([url]) + + if to_int(flag): + assert to_int(flag) == len(result) + + except Exception, e: + if isinstance(e, Fail) and flag == "fail": + pass + else: + raise + + +# setup methods + +c = Core() + +f = open(join(dirname(__file__), "crypterlinks.txt")) +links = [x.strip() for x in f.readlines()] +urls = [] +flags = {} + +for l in links: + if not l or l.startswith("#"): continue + if l.startswith("http"): + if "||" in l: + l, flag = l.split("||") + flags[l] = flag + + urls.append(l) + +h, crypter = c.pluginManager.parseUrls(urls) +plugins = accumulate(crypter) +for plugin, urls in plugins.iteritems(): + + for i, url in enumerate(urls): + + + def meta(plugin, url, flag, sig): + def _test(self): + self.test_plugin(plugin, url, flag) + + _test.func_name = sig + return _test + + sig = "test_%s_LINK%d" % (plugin, i) + setattr(CrypterPluginTester, sig, meta(plugin, url, flags.get(url, None), sig))
\ No newline at end of file |