mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ldb:tests: make api_base module
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
16820c883d
commit
6e947a20ee
@ -12,25 +12,12 @@ import ldb
|
||||
import shutil
|
||||
import errno
|
||||
|
||||
|
||||
TDB_PREFIX = "tdb://"
|
||||
MDB_PREFIX = "mdb://"
|
||||
|
||||
MDB_INDEX_OBJ = {
|
||||
"dn": "@INDEXLIST",
|
||||
"@IDXONE": [b"1"],
|
||||
"@IDXGUID": [b"objectUUID"],
|
||||
"@IDX_DN_GUID": [b"GUID"]
|
||||
}
|
||||
|
||||
|
||||
def tempdir():
|
||||
import tempfile
|
||||
try:
|
||||
dir_prefix = os.path.join(os.environ["SELFTEST_PREFIX"], "tmp")
|
||||
except KeyError:
|
||||
dir_prefix = None
|
||||
return tempfile.mkdtemp(dir=dir_prefix)
|
||||
from api_base import (
|
||||
MDB_PREFIX,
|
||||
MDB_INDEX_OBJ,
|
||||
tempdir,
|
||||
LdbBaseTest
|
||||
)
|
||||
|
||||
|
||||
class NoContextTests(TestCase):
|
||||
@ -74,25 +61,6 @@ class NoContextTests(TestCase):
|
||||
self.assertEqual(encoded2, encoded)
|
||||
|
||||
|
||||
class LdbBaseTest(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
try:
|
||||
if self.prefix is None:
|
||||
self.prefix = TDB_PREFIX
|
||||
except AttributeError:
|
||||
self.prefix = TDB_PREFIX
|
||||
|
||||
def url(self):
|
||||
return self.prefix + self.filename
|
||||
|
||||
def flags(self):
|
||||
if self.prefix == MDB_PREFIX:
|
||||
return ldb.FLG_NOSYNC
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
class SimpleLdb(LdbBaseTest):
|
||||
|
||||
def setUp(self):
|
||||
|
48
lib/ldb/tests/python/api_base.py
Normal file
48
lib/ldb/tests/python/api_base.py
Normal file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
# Simple tests for the ldb python bindings.
|
||||
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
|
||||
|
||||
import os
|
||||
from unittest import TestCase
|
||||
import sys
|
||||
sys.path.insert(0, "bin/python")
|
||||
import ldb
|
||||
|
||||
|
||||
TDB_PREFIX = "tdb://"
|
||||
MDB_PREFIX = "mdb://"
|
||||
|
||||
MDB_INDEX_OBJ = {
|
||||
"dn": "@INDEXLIST",
|
||||
"@IDXONE": [b"1"],
|
||||
"@IDXGUID": [b"objectUUID"],
|
||||
"@IDX_DN_GUID": [b"GUID"]
|
||||
}
|
||||
|
||||
|
||||
def tempdir():
|
||||
import tempfile
|
||||
try:
|
||||
dir_prefix = os.path.join(os.environ["SELFTEST_PREFIX"], "tmp")
|
||||
except KeyError:
|
||||
dir_prefix = None
|
||||
return tempfile.mkdtemp(dir=dir_prefix)
|
||||
|
||||
|
||||
class LdbBaseTest(TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
try:
|
||||
if self.prefix is None:
|
||||
self.prefix = TDB_PREFIX
|
||||
except AttributeError:
|
||||
self.prefix = TDB_PREFIX
|
||||
|
||||
def url(self):
|
||||
return self.prefix + self.filename
|
||||
|
||||
def flags(self):
|
||||
if self.prefix == MDB_PREFIX:
|
||||
return ldb.FLG_NOSYNC
|
||||
else:
|
||||
return 0
|
Loading…
Reference in New Issue
Block a user