summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-18 18:45:13 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-18 18:45:13 +0100
commit453c1e55c71a96c9529ecdca1d55278cc41088d6 (patch)
tree7a516a84e5590ce5f1f3def71c24bcb14f209023 /tests
parentsmall fixes and improvements for download engine (diff)
downloadpyload-453c1e55c71a96c9529ecdca1d55278cc41088d6.tar.xz
rewritten download scheduling, improved account manager, db version increased all data will be overwritten
Diffstat (limited to 'tests')
-rw-r--r--tests/config/pyload.conf.org76
-rw-r--r--tests/config/pyload.db.orgbin27648 -> 27648 bytes
-rw-r--r--tests/helper/Stubs.py14
-rw-r--r--tests/manager/test_accountManager.py22
-rw-r--r--tests/manager/test_downloadManager.py28
-rw-r--r--tests/other/test_statsDB.py13
6 files changed, 61 insertions, 92 deletions
diff --git a/tests/config/pyload.conf.org b/tests/config/pyload.conf.org
index 0a422f258..9d3611e4e 100644
--- a/tests/config/pyload.conf.org
+++ b/tests/config/pyload.conf.org
@@ -1,75 +1 @@
-version: 2
-
-[remote]
-nolocalauth = False
-activated = True
-port = 7558
-listenaddr = 127.0.0.1
-
-[log]
-log_size = 100
-log_folder = Logs
-file_log = False
-log_count = 5
-log_rotate = True
-
-[permission]
-group = users
-change_dl = False
-change_file = False
-user = user
-file = 0644
-change_group = False
-folder = 0755
-change_user = False
-
-[general]
-language = en
-download_folder = Downloads
-checksum = False
-folder_per_package = True
-debug_mode = True
-min_free_space = 200
-renice = 0
-
-[ssl]
-cert = ssl.crt
-activated = False
-key = ssl.key
-
-[webinterface]
-template = default
-activated = True
-prefix =
-server = builtin
-host = 127.0.0.1
-https = False
-port = 8921
-
-[proxy]
-username =
-proxy = False
-address = localhost
-password =
-type = http
-port = 7070
-
-[reconnect]
-endTime = 0:00
-activated = False
-method = ./reconnect.sh
-startTime = 0:00
-
-[download]
-max_downloads = 3
-limit_speed = False
-interface =
-skip_existing = False
-max_speed = -1
-ipv6 = False
-chunks = 3
-
-[downloadTime]
-start = 0:00
-end = 0:00
-
+version:2 \ No newline at end of file
diff --git a/tests/config/pyload.db.org b/tests/config/pyload.db.org
index 26af474c1..6fb8de6c1 100644
--- a/tests/config/pyload.db.org
+++ b/tests/config/pyload.db.org
Binary files differ
diff --git a/tests/helper/Stubs.py b/tests/helper/Stubs.py
index 3541e4ffb..4bb8ade9e 100644
--- a/tests/helper/Stubs.py
+++ b/tests/helper/Stubs.py
@@ -1,20 +1,22 @@
# -*- coding: utf-8 -*-
+import sys
from os.path import join
from time import strftime
from traceback import format_exc
import __builtin__
+from pyload.InitHomeDir import init_dir
+
+init_dir(join("tests", "config"), True)
+
from pyload.Api import Role
from pyload.Core import Core
-from pyload.InitHomeDir import init_dir
from pyload.datatypes.User import User
from pyload.threads.BaseThread import BaseThread
from pyload.config.ConfigParser import ConfigParser
-init_dir(join("tests", "config"))
-
from logging import log, DEBUG, INFO, WARN, ERROR
# Do nothing
@@ -94,3 +96,9 @@ adminUser = User(None, uid=0, role=Role.Admin)
normalUser = User(None, uid=1, role=Role.User)
otherUser = User(None, uid=2, role=Role.User)
+# fixes the module paths because we changed the directory
+for name, m in sys.modules.iteritems():
+ if not name.startswith("tests") or not m or not hasattr(m, "__path__"):
+ continue
+
+ m.__path__[0] = join("..", "..", m.__path__[0]) \ No newline at end of file
diff --git a/tests/manager/test_accountManager.py b/tests/manager/test_accountManager.py
index b7166b2bd..dccba9d7c 100644
--- a/tests/manager/test_accountManager.py
+++ b/tests/manager/test_accountManager.py
@@ -4,6 +4,8 @@ from unittest import TestCase
from tests.helper.Stubs import Core, adminUser, normalUser
+from pyload.AccountManager import AccountManager
+
class TestAccountManager(TestCase):
@classmethod
@@ -17,19 +19,20 @@ class TestAccountManager(TestCase):
def setUp(self):
self.db.purgeAccounts()
- self.manager = self.core.accountManager
+ self.manager = AccountManager(self.core)
def test_access(self):
- account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+ account = self.manager.createAccount("Http", "User", "somepw", adminUser.uid)
- assert account is self.manager.updateAccount("Http", "User", "newpw", adminUser)
+ assert account is self.manager.updateAccount(account.aid, "Http", "User", "newpw", adminUser)
self.assertEqual(account.password, "newpw")
- assert self.manager.getAccount("Http", "User") is account
- assert self.manager.getAccount("Http", "User", normalUser) is None
+ assert self.manager.getAccount(account.aid, "Http", adminUser) is account
+ assert self.manager.getAccount(account.aid, "Http", normalUser) is None
+
def test_config(self):
- account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+ account = self.manager.createAccount("Http", "User", "somepw", adminUser.uid)
info = account.toInfoData()
self.assertEqual(info.config[0].name, "domain")
@@ -48,7 +51,7 @@ class TestAccountManager(TestCase):
def test_shared(self):
- account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+ account = self.manager.createAccount("Http", "User", "somepw", adminUser.uid)
assert self.manager.selectAccount("Http", adminUser) is account
assert account.loginname == "User"
@@ -61,5 +64,10 @@ class TestAccountManager(TestCase):
assert self.manager.selectAccount("Http", normalUser) is account
assert self.manager.selectAccount("sdf", normalUser) is None
+ self.manager.removeAccount(account.aid, "Http", adminUser.uid)
+
+ assert self.manager.selectAccount("Http", adminUser) is None
+
+
diff --git a/tests/manager/test_downloadManager.py b/tests/manager/test_downloadManager.py
index 9906ca1a0..305451d7f 100644
--- a/tests/manager/test_downloadManager.py
+++ b/tests/manager/test_downloadManager.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from tests.helper.Stubs import Core, normalUser, adminUser
+from tests.helper.Stubs import Core, normalUser, adminUser, otherUser
from tests.helper.BenchmarkTest import BenchmarkTest
from pyload.database import DatabaseBackend
@@ -9,13 +9,21 @@ DatabaseBackend.async = DatabaseBackend.queue
class TestDownloadManager(BenchmarkTest):
- bench = ["add_links", "db"]
+ bench = ["add_links", "simple", "empty"]
+
+ USER = 2
+ PACKAGES = 10
+ LINKS = 50
+ PLUGINS = 10
@classmethod
def setUpClass(cls):
cls.c = Core()
cls.db = cls.c.db
cls.db.purgeAll()
+ cls.db.addDebugUser(normalUser.uid)
+ cls.db.addDebugUser(adminUser.uid)
+ cls.db.addDebugUser(otherUser.uid)
cls.files = cls.c.files
cls.m = cls.c.downloadManager
@@ -30,12 +38,18 @@ class TestDownloadManager(BenchmarkTest):
def test_add_links(self):
# just generate some links and files
- for i in range(10):
- pid = self.files.addPackage("name %d", "folder", -1, "", "", "", False, normalUser.uid)
- self.files.addLinks([("plugin%d" % i, "url%d" %i) for i in range(50)], pid, normalUser.uid)
+ for user in (adminUser, normalUser):
+ for i in range(self.PACKAGES):
+ pid = self.files.addPackage("name %d", "folder", -1, "", "", "", False, user.uid)
+ self.files.addLinks([( "url%d" %i, "plugin%d" % (i % self.PLUGINS)) for i in range(self.LINKS)], pid, user.uid)
+
+ def test_simple(self):
+ jobs = self.db.getJobs([])
+ assert len(jobs) == 2
+
+ def test_empty(self):
+ assert not self.db.getJobs(["plugin%d" % i for i in range(self.PLUGINS)])
- def test_db(self):
- pass
if __name__ == "__main__":
diff --git a/tests/other/test_statsDB.py b/tests/other/test_statsDB.py
new file mode 100644
index 000000000..f311b181e
--- /dev/null
+++ b/tests/other/test_statsDB.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+
+from tests.helper.Stubs import Core
+
+class TestStatDatabase():
+
+ @classmethod
+ def setUpClass(cls):
+ cls.core = Core()
+ cls.db = cls.core.db
+
+ def test_simple(self):
+ assert 1 == 0 \ No newline at end of file