From: Douglas Bagnall Date: Sat, 17 Aug 2024 02:46:05 +0000 (+1200) Subject: ldb:tests: make api_simple module X-Git-Tag: tdb-1.4.13~1172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=081125f3b319ca8807f0f4d9b5f279ab4dacced5;p=thirdparty%2Fsamba.git ldb:tests: make api_simple module Signed-off-by: Douglas Bagnall Reviewed-by: Andreas Schneider --- diff --git a/lib/ldb/tests/python/api.py b/lib/ldb/tests/python/api.py index 5499694e86c..5b36342ed52 100755 --- a/lib/ldb/tests/python/api.py +++ b/lib/ldb/tests/python/api.py @@ -7,7 +7,6 @@ from unittest import TestCase import sys sys.path.insert(0, "bin/python") import ldb -import shutil import errno from api_base import ( @@ -59,737 +58,6 @@ class NoContextTests(TestCase): self.assertEqual(encoded2, encoded) -class SimpleLdb(LdbBaseTest): - - def setUp(self): - super().setUp() - self.testdir = tempdir() - self.filename = os.path.join(self.testdir, "test.ldb") - self.ldb = ldb.Ldb(self.url(), flags=self.flags()) - try: - self.ldb.add(self.index) - except AttributeError: - pass - - def tearDown(self): - self.ldb.disconnect() - shutil.rmtree(self.testdir) - super().tearDown() - # Ensure the LDB is closed now, so we close the FD - - def test_connect(self): - ldb.Ldb(self.url(), flags=self.flags()) - - def test_connect_none(self): - ldb.Ldb() - - def test_connect_later(self): - x = ldb.Ldb() - x.connect(self.url(), flags=self.flags()) - - def test_connect_twice(self): - url = self.url() - x = ldb.Ldb(url) - with self.assertRaises(ldb.LdbError): - x.connect(url, flags=self.flags()) - - def test_connect_twice_later(self): - url = self.url() - flags = self.flags() - x = ldb.Ldb() - x.connect(url, flags) - with self.assertRaises(ldb.LdbError): - x.connect(url, flags) - - def test_connect_and_disconnect(self): - url = self.url() - flags = self.flags() - x = ldb.Ldb() - x.connect(url, flags) - x.disconnect() - x.connect(url, flags) - x.disconnect() - - def test_repr(self): - x = ldb.Ldb() - self.assertTrue(repr(x).startswith(" + +import os +import sys +sys.path.insert(0, "bin/python") +from api_base import ( + MDB_PREFIX, + MDB_INDEX_OBJ, + tempdir, + LdbBaseTest +) + +import ldb +import shutil + + +class SimpleLdb(LdbBaseTest): + + def setUp(self): + super().setUp() + self.testdir = tempdir() + self.filename = os.path.join(self.testdir, "test.ldb") + self.ldb = ldb.Ldb(self.url(), flags=self.flags()) + try: + self.ldb.add(self.index) + except AttributeError: + pass + + def tearDown(self): + self.ldb.disconnect() + shutil.rmtree(self.testdir) + super().tearDown() + # Ensure the LDB is closed now, so we close the FD + + def test_connect(self): + ldb.Ldb(self.url(), flags=self.flags()) + + def test_connect_none(self): + ldb.Ldb() + + def test_connect_later(self): + x = ldb.Ldb() + x.connect(self.url(), flags=self.flags()) + + def test_connect_twice(self): + url = self.url() + x = ldb.Ldb(url) + with self.assertRaises(ldb.LdbError): + x.connect(url, flags=self.flags()) + + def test_connect_twice_later(self): + url = self.url() + flags = self.flags() + x = ldb.Ldb() + x.connect(url, flags) + with self.assertRaises(ldb.LdbError): + x.connect(url, flags) + + def test_connect_and_disconnect(self): + url = self.url() + flags = self.flags() + x = ldb.Ldb() + x.connect(url, flags) + x.disconnect() + x.connect(url, flags) + x.disconnect() + + def test_repr(self): + x = ldb.Ldb() + self.assertTrue(repr(x).startswith("