From: Lumir Balhar Date: Wed, 11 Oct 2017 11:05:01 +0000 (+0200) Subject: tests: Improve tests of samba.registry Python module X-Git-Tag: tevent-0.9.34~188 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88dc82d1f9d8b415f8bc3dc4272a9c2c12e5ad80;p=thirdparty%2Fsamba.git tests: Improve tests of samba.registry Python module Signed-off-by: Lumir Balhar Reviewed-by: Andrew Bartlet Reviewed-by: Andreas Schneider --- diff --git a/python/samba/tests/registry.py b/python/samba/tests/registry.py index 8016a0bb686..1a8a1266b82 100644 --- a/python/samba/tests/registry.py +++ b/python/samba/tests/registry.py @@ -20,6 +20,9 @@ import os from samba import registry import samba.tests +from samba import WERRORError +from subprocess import Popen, PIPE + class HelperTests(samba.tests.TestCase): @@ -31,7 +34,6 @@ class HelperTests(samba.tests.TestCase): self.assertEquals("REG_DWORD", registry.str_regtype(4)) - class HiveTests(samba.tests.TestCaseInTempDir): def setUp(self): @@ -47,14 +49,27 @@ class HiveTests(samba.tests.TestCaseInTempDir): def test_ldb_new(self): self.assertTrue(self.hive is not None) - #def test_flush(self): - # self.hive.flush() + def test_set_value(self): + self.assertIsNone(self.hive.set_value('foo1', 1, 'bar1')) + + def test_flush(self): + self.assertIsNone(self.hive.set_value('foo2', 1, 'bar2')) + self.assertIsNone(self.hive.flush()) + + proc = Popen(['bin/tdbdump', self.hive_path], stdout=PIPE, stderr=PIPE) + tdb_dump, err = proc.communicate() + self.assertTrue(b'DN=VALUE=FOO2,HIVE=NONE' in tdb_dump) + + def test_del_value(self): + self.assertIsNone(self.hive.set_value('foo3', 1, 'bar3')) + self.assertIsNone(self.hive.del_value('foo3')) - #def test_del_value(self): - # self.hive.del_value("FOO") + def test_del_nonexisting_value(self): + self.assertRaises(WERRORError, self.hive.del_value, 'foo4') class RegistryTests(samba.tests.TestCase): def test_new(self): self.registry = registry.Registry() + self.assertIsNotNone(self.registry) diff --git a/selftest/tests.py b/selftest/tests.py index 9d1d9d3908b..3e3ef84a5ec 100644 --- a/selftest/tests.py +++ b/selftest/tests.py @@ -55,7 +55,7 @@ else: planpythontestsuite("none", "samba.tests.blackbox.ndrdump") planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python']) planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True) -planpythontestsuite("none", "samba.tests.registry") +planpythontestsuite("none", "samba.tests.registry", py3_compatible=True) planpythontestsuite("none", "samba.tests.auth", py3_compatible=True) planpythontestsuite("none", "samba.tests.get_opt", py3_compatible=True) planpythontestsuite("none", "samba.tests.security", py3_compatible=True)