summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-06 15:54:52 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-06 15:54:52 +0100
commit6f8b5347dfa119a3df21f4ca8ba8c2b1537a726a (patch)
tree627c4d99f0aaa4c8022b70b3ebe72f201d924dd6 /tests
parentremoved unneeded stuff (diff)
downloadpyload-6f8b5347dfa119a3df21f4ca8ba8c2b1537a726a.tar.xz
first working parts of config api
Diffstat (limited to 'tests')
-rw-r--r--tests/manager/test_configManager.py26
-rw-r--r--tests/other/test_configparser.py5
2 files changed, 30 insertions, 1 deletions
diff --git a/tests/manager/test_configManager.py b/tests/manager/test_configManager.py
index 1cfb6a5de..0fed702c1 100644
--- a/tests/manager/test_configManager.py
+++ b/tests/manager/test_configManager.py
@@ -27,6 +27,9 @@ class TestConfigManager(TestCase):
def setUp(self):
self.db.clearAllConfigs()
+ # used by some tests, needs to be deleted
+ self.config.delete("plugin", adminUser)
+
def addConfig(self):
self.config.addConfigSection("plugin", "Name", "desc", "something",
@@ -42,10 +45,12 @@ class TestConfigManager(TestCase):
d = self.db.loadAllConfigs()
assert d[0]["plugin"] == "some value"
+ assert self.db.loadConfigsForUser(0)["plugin"] == "some value"
self.db.deleteConfig("plugin", 0)
assert 0 not in self.db.loadAllConfigs()
+ assert "plugin" not in self.db.loadConfigsForUser(0)
self.db.deleteConfig("plugin")
@@ -86,7 +91,26 @@ class TestConfigManager(TestCase):
def test_sections(self):
- pass
+ self.addConfig()
+
+ i = 0
+ # there should be only one section, with no values
+ for name, config, values in self.config.iterSections(adminUser):
+ assert name == "plugin"
+ assert values == {}
+ i +=1
+ assert i == 1
+
+ assert self.config.set("plugin", "value", True, user=adminUser)
+
+ i = 0
+ # now we assert the correct values
+ for name, config, values in self.config.iterSections(adminUser):
+ assert name == "plugin"
+ assert values == {"value":True}
+ i +=1
+ assert i == 1
+
@raises(InvalidConfigSection)
def test_restricted_access(self):
diff --git a/tests/other/test_configparser.py b/tests/other/test_configparser.py
index 51ffc5a68..09b686738 100644
--- a/tests/other/test_configparser.py
+++ b/tests/other/test_configparser.py
@@ -25,6 +25,11 @@ class TestConfigParser():
assert "general" in self.config
assert "foobaar" not in self.config
+ def test_iter(self):
+ for section, config, values in self.config.iterSections():
+ assert isinstance(section, basestring)
+ assert isinstance(config.config, dict)
+ assert isinstance(values, dict)
@raises(KeyError)
def test_invalid_config(self):