Changeset View
Changeset View
Standalone View
Standalone View
tests/unit/test-014-conf-and-raw.py
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||
import os | import os | ||||
import pykolab | import pykolab | ||||
import tempfile | import tempfile | ||||
import unittest | import unittest | ||||
conf = pykolab.getConf() | conf = pykolab.getConf() | ||||
conf.finalize_conf(fatal=False) | conf.finalize_conf(fatal=False) | ||||
class TestConfRaw(unittest.TestCase): | class TestConfRaw(unittest.TestCase): | ||||
config_file = None | config_file = None | ||||
@classmethod | @classmethod | ||||
def setup_class(self, *args, **kw): | def setup_class(self, *args, **kw): | ||||
(fp, self.config_file) = tempfile.mkstemp() | (fp, self.config_file) = tempfile.mkstemp() | ||||
os.write(fp, '[kolab]\n') | os.write(fp, '[kolab]\n') | ||||
os.close(fp) | os.close(fp) | ||||
conf.read_config(self.config_file) | conf.read_config(self.config_file) | ||||
@classmethod | @classmethod | ||||
def teardown_class(self, *args, **kw): | def teardown_class(self, *args, **kw): | ||||
os.remove(self.config_file) | os.remove(self.config_file) | ||||
def test_001_set(self): | def test_001_set(self): | ||||
password = '$%something' | password = '$%something' | ||||
conf.command_set('kolab', 'test_password', password) | conf.command_set('kolab', 'test_password', password) | ||||
def test_002_get(self): | def test_002_get(self): | ||||
password = conf.get('kolab', 'test_password') | password = conf.get('kolab', 'test_password') | ||||
self.assertEqual('$%something', password) | self.assertEqual('$%something', password) | ||||
def test_003_get_raw(self): | def test_003_get_raw(self): | ||||
password = conf.get_raw('kolab', 'test_password') | password = conf.get_raw('kolab', 'test_password') | ||||
self.assertNotEqual('$%something', password) | self.assertNotEqual('$%something', password) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
unittest.main() | unittest.main() |