file = param.LoadParm()
file.load_default()
-class ParamTestCase(unittest.TestCase):
- def test_init(self):
- file = param.ParamFile()
- self.assertTrue(file is not None)
-
- def test_add_section(self):
- file = param.ParamFile()
- file.add_section("global")
- self.assertTrue(file["global"] is not None)
-
- def test_set_param_string(self):
- file = param.ParamFile()
- file.add_section("global")
- file.set_string("data", "bar")
- self.assertEquals("bar", file.get_string("data"))
-
- def test_get_section(self):
- file = param.ParamFile()
- self.assertEquals(None, file.get_section("unknown"))
- self.assertRaises(KeyError, lambda: file["unknown"])
paths.netlogon = lp.get("path", "netlogon")
- paths.smbconf = lp.configfile()
+ paths.smbconf = lp.configfile
return paths
if lp.get("realm").upper() != realm:
raise Exception("realm '%s' in %s must match chosen realm '%s'" %
- (lp.get("realm"), lp.configfile(), realm))
+ (lp.get("realm"), lp.configfile, realm))
dnsdomain = dnsdomain.lower()
def __getitem__(self, section):
return self._sections[section]
+ def get_section(self, section):
+ return self._sections.get(section)
+
+ def add_section(self, section):
+ self._sections[self._sanitize_name(section)] = {}
+
+ def set_string(self, name, value):
+ self._sections["global"][name] = value
+
+ def get_string(self, name):
+ return self._sections["global"].get(name)
+
class Samba3(object):
"""Samba 3 configuration and state data reader."""
import unittest
from samba.samba3 import GroupMappingDatabase, Registry, PolicyDatabase, SecretsDatabase, TdbSam
-from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser
+from samba.samba3 import WinsDatabase, SmbpasswdFile, ACB_NORMAL, IdmapDatabase, SAMUser, ParamFile
import os
DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
def tearDown(self):
self.shareinfodb.close()
+
+
+class ParamTestCase(unittest.TestCase):
+ def test_init(self):
+ file = ParamFile()
+ self.assertTrue(file is not None)
+
+ def test_add_section(self):
+ file = ParamFile()
+ file.add_section("global")
+ self.assertTrue(file["global"] is not None)
+
+ def test_set_param_string(self):
+ file = ParamFile()
+ file.add_section("global")
+ file.set_string("data", "bar")
+ self.assertEquals("bar", file.get_string("data"))
+
+ def test_get_section(self):
+ file = ParamFile()
+ self.assertEquals(None, file.get_section("unknown"))
+ self.assertRaises(KeyError, lambda: file["unknown"])
break
lp = sambaopts.get_loadparm()
-smbconf = lp.configfile()
+smbconf = lp.configfile
if opts.aci is not None:
print "set ACI: %s" % opts.aci