diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2014-01-11 22:23:20 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2014-01-11 22:23:20 +0100 |
commit | 94c1cceae1e58c0b7cff09bef684751978d878e3 (patch) | |
tree | 9e2f9eebce7602431aaa24cbd5f8871e48e4ff3f /tests/manager | |
parent | fixed error from last commit (diff) | |
download | pyload-94c1cceae1e58c0b7cff09bef684751978d878e3.tar.xz |
small cleanup, fixed some test cases
Diffstat (limited to 'tests/manager')
-rw-r--r-- | tests/manager/test_accountManager.py | 9 | ||||
-rw-r--r-- | tests/manager/test_downloadManager.py | 42 | ||||
-rw-r--r-- | tests/manager/test_filemanager.py | 32 |
3 files changed, 58 insertions, 25 deletions
diff --git a/tests/manager/test_accountManager.py b/tests/manager/test_accountManager.py index 1b328f892..b7166b2bd 100644 --- a/tests/manager/test_accountManager.py +++ b/tests/manager/test_accountManager.py @@ -4,17 +4,12 @@ from unittest import TestCase from tests.helper.Stubs import Core, adminUser, normalUser -from pyload.database import DatabaseBackend -from pyload.AccountManager import AccountManager - class TestAccountManager(TestCase): @classmethod def setUpClass(cls): cls.core = Core() - cls.db = DatabaseBackend(cls.core) - cls.core.db = cls.db - cls.db.setup() + cls.db = cls.core.db @classmethod def tearDownClass(cls): @@ -22,7 +17,7 @@ class TestAccountManager(TestCase): def setUp(self): self.db.purgeAccounts() - self.manager = AccountManager(self.core) + self.manager = self.core.accountManager def test_access(self): account = self.manager.updateAccount("Http", "User", "somepw", adminUser) diff --git a/tests/manager/test_downloadManager.py b/tests/manager/test_downloadManager.py new file mode 100644 index 000000000..9906ca1a0 --- /dev/null +++ b/tests/manager/test_downloadManager.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +from tests.helper.Stubs import Core, normalUser, adminUser +from tests.helper.BenchmarkTest import BenchmarkTest + +from pyload.database import DatabaseBackend +# disable asyncronous queries +DatabaseBackend.async = DatabaseBackend.queue + +class TestDownloadManager(BenchmarkTest): + + bench = ["add_links", "db"] + + @classmethod + def setUpClass(cls): + cls.c = Core() + cls.db = cls.c.db + cls.db.purgeAll() + + cls.files = cls.c.files + cls.m = cls.c.downloadManager + + @classmethod + def tearDownClass(cls): + cls.db.purgeAll() + cls.db.shutdown() + + def setUp(self): + self.test_add_links() + + 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) + + def test_db(self): + pass + + +if __name__ == "__main__": + TestDownloadManager.benchmark()
\ No newline at end of file diff --git a/tests/manager/test_filemanager.py b/tests/manager/test_filemanager.py index a7507cada..212ea6d8c 100644 --- a/tests/manager/test_filemanager.py +++ b/tests/manager/test_filemanager.py @@ -2,7 +2,7 @@ from random import choice -from tests.helper.Stubs import Core +from tests.helper.Stubs import Core, normalUser from tests.helper.BenchmarkTest import BenchmarkTest from pyload.database import DatabaseBackend @@ -10,8 +10,6 @@ from pyload.database import DatabaseBackend DatabaseBackend.async = DatabaseBackend.queue from pyload.Api import DownloadState -from pyload.FileManager import FileManager - class TestFileManager(BenchmarkTest): bench = ["add_packages", "add_files", "get_files_root", "get", @@ -24,19 +22,17 @@ class TestFileManager(BenchmarkTest): @classmethod def setUpClass(cls): c = Core() - # db needs seperate initialisation - cls.db = c.db = DatabaseBackend(c) - cls.db.setup() + # db needs separate initialisation + cls.db = c.db cls.db.purgeAll() - cls.m = cls.db.manager = FileManager(c) + cls.m = cls.db.manager = c.files @classmethod def tearDownClass(cls): cls.db.purgeAll() cls.db.shutdown() - # benchmarker ignore setup def setUp(self): self.db.purgeAll() @@ -48,7 +44,7 @@ class TestFileManager(BenchmarkTest): def test_add_packages(self): for i in range(100): - pid = self.m.addPackage("name", "folder", choice(self.pids), "", "", "", False) + pid = self.m.addPackage("name", "folder", choice(self.pids), "", "", "", False, normalUser.uid) self.pids.append(pid) if -1 in self.pids: @@ -56,7 +52,7 @@ class TestFileManager(BenchmarkTest): def test_add_files(self): for pid in self.pids: - self.m.addLinks([("plugin %d" % i, "url %s" % i) for i in range(self.count)], pid) + self.m.addLinks([("plugin %d" % i, "url %s" % i) for i in range(self.count)], pid, normalUser.uid) count = self.m.getQueueStats()[0] files = self.count * len(self.pids) @@ -120,14 +116,14 @@ class TestFileManager(BenchmarkTest): for fid in view.root.fids: assert fid in view.files def test_delete(self): - self.m.deleteFile(self.count * 5) - self.m.deletePackage(choice(self.pids)) + self.m.removeFile(self.count * 5) + self.m.removePackage(choice(self.pids)) def test_order_package(self): - parent = self.m.addPackage("order", "", -1, "", "", "", False) - self.m.addLinks([("url", "plugin") for i in range(100)], parent) + parent = self.m.addPackage("order", "", -1, "", "", "", False, normalUser.uid) + self.m.addLinks([("url", "plugin") for i in range(100)], parent, normalUser.uid) - pids = [self.m.addPackage("c", "", parent, "", "", "", False) for i in range(5)] + pids = [self.m.addPackage("c", "", parent, "", "", "", False, normalUser.uid) for i in range(5)] v = self.m.getTree(parent, False, None) self.assert_ordered(pids, 0, 5, v.root.pids, v.packages, True) @@ -143,8 +139,8 @@ class TestFileManager(BenchmarkTest): def test_order_files(self): - parent = self.m.addPackage("order", "", -1, "", "", "", False) - self.m.addLinks([("url", "plugin") for i in range(100)], parent) + parent = self.m.addPackage("order", "", -1, "", "", "", False, normalUser.uid) + self.m.addLinks([("url", "plugin") for i in range(100)], parent, normalUser.uid) v = self.m.getTree(parent, False, None) fids = v.root.fids[10:20] @@ -206,7 +202,7 @@ class TestFileManager(BenchmarkTest): self.m.movePackage(pid, -1) v = self.m.getTree(-1, False, False) - assert v.root.pids[-1] == pid + assert pid in v.root.pids assert sorted([p.packageorder for p in v.packages.values()]) == range(len(v.packages)) v = self.m.getTree(pid, False, False) |