mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
python selftest: enabled samba.tests.s3registry to run with py3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
committed by
Andrew Bartlett
parent
8caa2cd48a
commit
1734655bf8
@ -19,7 +19,7 @@
|
||||
|
||||
__docformat__ = "restructuredText"
|
||||
|
||||
REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL"
|
||||
REGISTRY_VALUE_PREFIX = b"SAMBA_REGVAL"
|
||||
REGISTRY_DB_VERSION = 1
|
||||
|
||||
import os
|
||||
@ -79,7 +79,7 @@ class Registry(DbDatabase):
|
||||
|
||||
def keys(self):
|
||||
"""Return list with all the keys."""
|
||||
return [k.rstrip("\x00") for k in self.db.iterkeys() if not k.startswith(REGISTRY_VALUE_PREFIX)]
|
||||
return [k.rstrip(b"\x00") for k in self.db if not k.startswith(REGISTRY_VALUE_PREFIX)]
|
||||
|
||||
def subkeys(self, key):
|
||||
"""Retrieve the subkeys for the specified key.
|
||||
@ -87,12 +87,12 @@ class Registry(DbDatabase):
|
||||
:param key: Key path.
|
||||
:return: list with key names
|
||||
"""
|
||||
data = self.db.get("%s\x00" % key)
|
||||
data = self.db.get(b"%s\x00" % key)
|
||||
if data is None:
|
||||
return []
|
||||
(num, ) = struct.unpack("<L", data[0:4])
|
||||
keys = data[4:].split("\0")
|
||||
assert keys[-1] == ""
|
||||
keys = data[4:].split(b"\0")
|
||||
assert keys[-1] == b""
|
||||
keys.pop()
|
||||
assert len(keys) == num
|
||||
return keys
|
||||
@ -103,7 +103,7 @@ class Registry(DbDatabase):
|
||||
:param key: Key to retrieve values for.
|
||||
:return: Dictionary with value names as key, tuple with type and
|
||||
data as value."""
|
||||
data = self.db.get("%s/%s\x00" % (REGISTRY_VALUE_PREFIX, key))
|
||||
data = self.db.get(b"%s/%s\x00" % (REGISTRY_VALUE_PREFIX, key))
|
||||
if data is None:
|
||||
return {}
|
||||
ret = {}
|
||||
@ -111,7 +111,7 @@ class Registry(DbDatabase):
|
||||
data = data[4:]
|
||||
for i in range(num):
|
||||
# Value name
|
||||
(name, data) = data.split("\0", 1)
|
||||
(name, data) = data.split(b"\0", 1)
|
||||
|
||||
(type, ) = struct.unpack("<L", data[0:4])
|
||||
data = data[4:]
|
||||
|
@ -43,12 +43,12 @@ class RegistryTestCase(TestCase):
|
||||
self.assertEquals(28, len(self.registry))
|
||||
|
||||
def test_keys(self):
|
||||
self.assertTrue("HKLM" in self.registry.keys())
|
||||
self.assertTrue(b"HKLM" in self.registry.keys())
|
||||
|
||||
def test_subkeys(self):
|
||||
self.assertEquals(["SOFTWARE", "SYSTEM"], self.registry.subkeys("HKLM"))
|
||||
self.assertEquals([b"SOFTWARE", b"SYSTEM"], self.registry.subkeys(b"HKLM"))
|
||||
|
||||
def test_values(self):
|
||||
self.assertEquals({'DisplayName': (1L, 'E\x00v\x00e\x00n\x00t\x00 \x00L\x00o\x00g\x00\x00\x00'),
|
||||
'ErrorControl': (4L, '\x01\x00\x00\x00')},
|
||||
self.registry.values("HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/EVENTLOG"))
|
||||
self.assertEquals({b'DisplayName': (1, b'E\x00v\x00e\x00n\x00t\x00 \x00L\x00o\x00g\x00\x00\x00'),
|
||||
b'ErrorControl': (4, b'\x01\x00\x00\x00')},
|
||||
self.registry.values(b"HKLM/SYSTEM/CURRENTCONTROLSET/SERVICES/EVENTLOG"))
|
||||
|
@ -77,7 +77,7 @@ planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.messaging",
|
||||
py3_compatible=True)
|
||||
planpythontestsuite("none", "samba.tests.s3param", py3_compatible=True)
|
||||
planpythontestsuite("none", "samba.tests.s3passdb", py3_compatible=True)
|
||||
planpythontestsuite("none", "samba.tests.s3registry")
|
||||
planpythontestsuite("none", "samba.tests.s3registry", py3_compatible=True)
|
||||
planpythontestsuite("none", "samba.tests.s3windb")
|
||||
planpythontestsuite("none", "samba.tests.s3idmapdb")
|
||||
planpythontestsuite("none", "samba.tests.samba3sam")
|
||||
|
Reference in New Issue
Block a user