summaryrefslogtreecommitdiffstats
path: root/tests/manager
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manager')
-rw-r--r--tests/manager/test_accountManager.py22
-rw-r--r--tests/manager/test_downloadManager.py28
2 files changed, 36 insertions, 14 deletions
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__":