summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/api/ApiProxy.py4
-rw-r--r--tests/api/ApiTester.py6
-rw-r--r--tests/api/test_JSONBackend.py15
-rw-r--r--tests/api/test_WebSocketBackend.py10
-rw-r--r--tests/api/test_api.py17
-rw-r--r--tests/config/plugin.conf138
-rw-r--r--tests/config/pyload.conf.org4
-rw-r--r--tests/config/pyload.db.orgbin13312 -> 27648 bytes
-rw-r--r--tests/helper/config.py9
-rwxr-xr-xtests/nosetests.sh2
-rw-r--r--tests/other/test_syntax.py5
-rwxr-xr-xtests/run_pyload.sh11
12 files changed, 56 insertions, 165 deletions
diff --git a/tests/api/ApiProxy.py b/tests/api/ApiProxy.py
index 4bea0f5a3..0da79a204 100644
--- a/tests/api/ApiProxy.py
+++ b/tests/api/ApiProxy.py
@@ -3,10 +3,12 @@
from pyload.remote.apitypes_debug import classes, methods
+from tests.helper.config import credentials
+
class ApiProxy:
""" Proxy that does type checking on the api """
- def __init__(self, api, user="User", pw="test"):
+ def __init__(self, api, user=credentials[0], pw=credentials[1]):
self.api = api
self.user = user
self.pw = pw
diff --git a/tests/api/ApiTester.py b/tests/api/ApiTester.py
index 39973b52f..e9a185947 100644
--- a/tests/api/ApiTester.py
+++ b/tests/api/ApiTester.py
@@ -3,6 +3,8 @@
from pyload.remote.JSONClient import JSONClient
from pyload.remote.WSClient import WSClient
+from tests.helper.config import webAddress, wsAddress
+
from ApiProxy import ApiProxy
class ApiTester:
@@ -29,7 +31,7 @@ class ApiTester:
self.api = api
def enableJSON(self):
- self.api = ApiProxy(JSONClient())
+ self.api = ApiProxy(JSONClient(webAddress))
def enableWS(self):
- self.api = ApiProxy(WSClient())
+ self.api = ApiProxy(WSClient(wsAddress))
diff --git a/tests/api/test_JSONBackend.py b/tests/api/test_JSONBackend.py
index 4efc65d2a..d13d6709f 100644
--- a/tests/api/test_JSONBackend.py
+++ b/tests/api/test_JSONBackend.py
@@ -10,15 +10,15 @@ import json
from pyload.remote.apitypes import Forbidden
from pyload.remote.JSONClient import JSONClient
+from tests.helper.config import credentials, webAddress
class TestJSONBackend:
- login = ("User", "pwhere")
def setUp(self):
- self.client = JSONClient()
+ self.client = JSONClient(webAddress)
def test_login(self):
- self.client.login(*self.login)
+ self.client.login(*credentials)
self.client.getServerVersion()
self.client.logout()
@@ -26,10 +26,9 @@ class TestJSONBackend:
ret = self.client.login("WrongUser", "wrongpw")
assert ret is False
-
def test_httpauth(self):
# cheap http auth
- ret = requests.get(self.client.URL + "/getServerVersion", auth=HTTPBasicAuth(*self.login))
+ ret = requests.get(webAddress + "/getServerVersion", auth=HTTPBasicAuth(*credentials))
assert_equal(ret.status_code, 200)
assert ret.text
@@ -37,8 +36,8 @@ class TestJSONBackend:
payload = {'section': 'webinterface', 'option': 'port'}
headers = {'content-type': 'application/json'}
- ret = requests.get(self.client.URL + "/getConfigValue", headers=headers,
- auth=HTTPBasicAuth(*self.login), data=json.dumps(payload))
+ ret = requests.get(webAddress + "/getConfigValue", headers=headers,
+ auth=HTTPBasicAuth(*credentials), data=json.dumps(payload))
assert_equal(ret.status_code, 200)
assert ret.text
@@ -49,5 +48,5 @@ class TestJSONBackend:
@raises(AttributeError)
def test_unknown_method(self):
- self.client.login(*self.login)
+ self.client.login(*credentials)
self.client.sdfdsg() \ No newline at end of file
diff --git a/tests/api/test_WebSocketBackend.py b/tests/api/test_WebSocketBackend.py
index 679654fc9..a9288104f 100644
--- a/tests/api/test_WebSocketBackend.py
+++ b/tests/api/test_WebSocketBackend.py
@@ -5,23 +5,25 @@ from nose.tools import raises
from pyload.remote.apitypes import Forbidden
from pyload.remote.WSClient import WSClient
+from tests.helper.config import credentials, wsAddress
+
class TestWebSocketBackend:
def setUp(self):
- self.client = WSClient()
+ self.client = WSClient(wsAddress)
self.client.connect()
def tearDown(self):
self.client.close()
def test_login(self):
- self.client.login("User", "test")
+ self.client.login(*credentials)
self.client.getServerVersion()
self.client.logout()
def test_wronglogin(self):
ret = self.client.login("WrongUser", "wrongpw")
- assert ret == False
+ assert ret is False
@raises(Forbidden)
def test_access(self):
@@ -29,5 +31,5 @@ class TestWebSocketBackend:
@raises(AttributeError)
def test_unknown_method(self):
- self.client.login("User", "test")
+ self.client.login(*credentials)
self.client.sdfdsg()
diff --git a/tests/api/test_api.py b/tests/api/test_api.py
index 68448b891..668470fe4 100644
--- a/tests/api/test_api.py
+++ b/tests/api/test_api.py
@@ -1,17 +1,19 @@
-
from unittest import TestCase
from random import choice
-from pyLoadCore import Core
+from pyload.Core import Core
from ApiTester import ApiTester
+
class TestAPI(TestCase):
"""
Test all available testers randomly and on all backends
"""
+ _multiprocess_can_split_ = True
core = None
+ #TODO: parallel testing
@classmethod
def setUpClass(cls):
from test_noargs import TestNoArgs
@@ -33,7 +35,16 @@ class TestAPI(TestCase):
cls.core.shutdown()
def test_random(self, n=10000):
-
for i in range(n):
func = choice(self.methods)
func()
+
+ def test_random2(self, n):
+ self.test_random(n)
+
+ def test_random3(self, n):
+ self.test_random(n)
+
+ def test_random4(self, n):
+ self.test_random(n)
+
diff --git a/tests/config/plugin.conf b/tests/config/plugin.conf
deleted file mode 100644
index 5e7ee3858..000000000
--- a/tests/config/plugin.conf
+++ /dev/null
@@ -1,138 +0,0 @@
-version: 2
-
-[MultiuploadCom]
-preferedHoster = multiupload
-ignoredHoster =
-
-[SerienjunkiesOrg]
-preferredHoster = RapidshareCom,UploadedTo,NetloadIn,FilefactoryCom,FreakshareNet,FilebaseTo,MegauploadCom,HotfileCom,DepositfilesCom,EasyshareCom,KickloadCom
-changeName = True
-
-[EmbeduploadCom]
-preferedHoster = embedupload
-ignoredHoster =
-
-[MultiloadCz]
-usedHoster =
-ignoredHoster =
-
-[WiiReloadedOrg]
-changeName = True
-
-[Xdcc]
-nick = pyload
-ident = pyloadident
-realname = pyloadreal
-
-[UlozTo]
-reuseCaptcha = True
-captchaUser =
-captchaNb =
-
-[YoutubeCom]
-quality = hd
-fmt = 0
-.mp4 = True
-.flv = True
-.webm = False
-.3gp = False
-
-[RapidshareCom]
-server = None
-
-[VeehdCom]
-filename_spaces = False
-replacement_char = _
-
-[RealdebridCom]
-https = False
-
-[ClickAndLoad]
-activated = True
-extern = False
-
-[ExtractArchive]
-activated = True
-fullpath = True
-overwrite = True
-passwordfile = unrar_passwords.txt
-deletearchive = False
-subfolder = False
-destination =
-queue = True
-renice = 0
-
-[CaptchaTrader]
-activated = True
-username =
-force = False
-passkey =
-
-[MergeFiles]
-activated = False
-
-[IRCInterface]
-activated = False
-host = Enter your server here!
-port = 6667
-ident = pyload-irc
-realname = pyload-irc
-nick = pyLoad-IRC
-owner = Enter your nick here!
-info_file = False
-info_pack = True
-captcha = True
-
-[Ev0InFetcher]
-activated = False
-interval = 10
-queue = False
-shows =
-quality = xvid
-hoster = NetloadIn,RapidshareCom,MegauploadCom,HotfileCom
-
-[EasybytezCom]
-activated = False
-includeHoster =
-excludeHoster =
-
-[XMPPInterface]
-activated = False
-jid = user@exmaple-jabber-server.org
-pw =
-tls = False
-owners = me@icq-gateway.org;some@msn-gateway.org
-info_file = False
-info_pack = True
-captcha = True
-
-[RehostTo]
-activated = False
-
-[MultiHoster]
-activated = True
-
-[MultiHome]
-activated = False
-interfaces = None
-
-[MultishareCz]
-activated = False
-includeHoster =
-excludeHoster = rapidshare.com|uloz.to
-
-[HotFolder]
-activated = False
-folder = container
-watch_file = False
-keep = True
-file = links.txt
-
-[ExternalScripts]
-activated = True
-
-[UpdateManager]
-activated = True
-interval = 360
-debug = False
-
diff --git a/tests/config/pyload.conf.org b/tests/config/pyload.conf.org
index 7fb1c8c87..0a422f258 100644
--- a/tests/config/pyload.conf.org
+++ b/tests/config/pyload.conf.org
@@ -3,7 +3,7 @@ version: 2
[remote]
nolocalauth = False
activated = True
-port = 7227
+port = 7558
listenaddr = 127.0.0.1
[log]
@@ -44,7 +44,7 @@ prefix =
server = builtin
host = 127.0.0.1
https = False
-port = 8001
+port = 8921
[proxy]
username =
diff --git a/tests/config/pyload.db.org b/tests/config/pyload.db.org
index d340531c5..26af474c1 100644
--- a/tests/config/pyload.db.org
+++ b/tests/config/pyload.db.org
Binary files differ
diff --git a/tests/helper/config.py b/tests/helper/config.py
new file mode 100644
index 000000000..81f7e6768
--- /dev/null
+++ b/tests/helper/config.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+# Test configuration
+credentials = ("TestUser", "pwhere")
+webPort = 8921
+wsPort = 7558
+
+webAddress = "http://localhost:%d/api" % webPort
+wsAddress = "ws://localhost:%d/api" % wsPort \ No newline at end of file
diff --git a/tests/nosetests.sh b/tests/nosetests.sh
index c68861b90..5b277ecb8 100755
--- a/tests/nosetests.sh
+++ b/tests/nosetests.sh
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
NS=nosetests
which nosetests2 > /dev/null && NS=nosetests2
-$NS tests/ --with-coverage --with-xunit --cover-package=module --cover-erase
+$NS tests/ --with-coverage --with-xunit --cover-package=pyload --cover-erase --process-timeout=60
coverage xml
diff --git a/tests/other/test_syntax.py b/tests/other/test_syntax.py
index fbf7edf8f..396fc8f4b 100644
--- a/tests/other/test_syntax.py
+++ b/tests/other/test_syntax.py
@@ -14,7 +14,7 @@ class TestSyntax(TestCase):
pass
-for path, dirs, files in walk(join(PATH, "module")):
+for path, dirs, files in walk(join(PATH, "pyload")):
for f in files:
if not f.endswith(".py") or f.startswith("__"): continue
@@ -26,7 +26,6 @@ for path, dirs, files in walk(join(PATH, "module")):
# to much sideeffect when importing
if "web" in packages or "lib" in packages: continue
- if "ThriftTest" in packages: continue
# currying
def meta(imp, sig):
@@ -38,6 +37,4 @@ for path, dirs, files in walk(join(PATH, "module")):
# generate test methods
sig = "test_%s_%s" % (packages[-2], packages[-1])
-
-
setattr(TestSyntax, sig, meta(imp, sig)) \ No newline at end of file
diff --git a/tests/run_pyload.sh b/tests/run_pyload.sh
index c272ad3c7..9ffc04b4f 100755
--- a/tests/run_pyload.sh
+++ b/tests/run_pyload.sh
@@ -1,4 +1,11 @@
-#/usr/bin/env bash
+#!/usr/bin/env bash
+
+PIDFILE="tests/pyload.pid"
+if [ -f "$PIDFILE" ]
+then
+ kill -9 $(<"$PIDFILE")
+fi
+
cp tests/config/pyload.db.org tests/config/pyload.db
cp tests/config/pyload.conf.org tests/config/pyload.conf
@@ -9,7 +16,7 @@ touch pyload.out
$PYTHON pyload.py -d --configdir=tests/config > pyload.out 2> pyload.err &
for i in {1..30}; do
- grep 8001 pyload.out > /dev/null && echo "pyLoad started" && break
+ grep "pyLoad is up and running" pyload.out > /dev/null && echo "pyLoad started" && break
sleep 1
done