summaryrefslogtreecommitdiffstats
path: root/tests/manager/test_accountManager.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-08-08 17:38:35 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-08-08 17:38:35 +0200
commit52f6599748ef61219112111dc5db71f3342b076d (patch)
treee3627ded64b7e98493ca1ec7bd182aaa1774252e /tests/manager/test_accountManager.py
parentMultiHosters: moved settings to addon plugins. (diff)
downloadpyload-52f6599748ef61219112111dc5db71f3342b076d.tar.xz
adapted account api to multi user, fixed http referer bug
Diffstat (limited to 'tests/manager/test_accountManager.py')
-rw-r--r--tests/manager/test_accountManager.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/manager/test_accountManager.py b/tests/manager/test_accountManager.py
new file mode 100644
index 000000000..1b328f892
--- /dev/null
+++ b/tests/manager/test_accountManager.py
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+
+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()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.db.shutdown()
+
+ def setUp(self):
+ self.db.purgeAccounts()
+ self.manager = AccountManager(self.core)
+
+ def test_access(self):
+ account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+
+ assert account is self.manager.updateAccount("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
+
+ def test_config(self):
+ account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+ info = account.toInfoData()
+
+ self.assertEqual(info.config[0].name, "domain")
+ self.assertEqual(info.config[0].value, "")
+ self.assertEqual(account.getConfig("domain"), "")
+
+ account.setConfig("domain", "df")
+
+ info = account.toInfoData()
+ self.assertEqual(info.config[0].value, "df")
+
+ info.config[0].value = "new"
+
+ account.updateConfig(info.config)
+ self.assertEqual(account.getConfig("domain"), "new")
+
+
+ def test_shared(self):
+ account = self.manager.updateAccount("Http", "User", "somepw", adminUser)
+
+ assert self.manager.selectAccount("Http", adminUser) is account
+ assert account.loginname == "User"
+
+ assert self.manager.selectAccount("Something", adminUser) is None
+ assert self.manager.selectAccount("Http", normalUser) is None
+
+ account.shared = True
+
+ assert self.manager.selectAccount("Http", normalUser) is account
+ assert self.manager.selectAccount("sdf", normalUser) is None
+
+
+