s4-torture: fix type of enum in various places
[Samba.git] / python / samba / tests / tdb_util.py
blob93c83a87910b7bc75fbc77192e6012c93c55c246
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Lumir Balhar <lbalhar@redhat.com> 2017
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import samba.tests
19 from samba import ldb, Ldb
20 from samba.tdb_util import tdb_copy
21 import os
24 class TDBUtilTests(samba.tests.TestCaseInTempDir):
26 def setUp(self):
27 super(TDBUtilTests, self).setUp()
29 def test_tdb_copy(self):
30 src_ldb_file = os.path.join(self.tempdir, "source.ldb")
31 dst_ldb_file = os.path.join(self.tempdir, "destination.ldb")
33 # Create LDB source file with some content
34 src_ldb = Ldb(src_ldb_file)
35 src_ldb.add({"dn": "f=dc", "b": "bla"})
37 # Copy source file to destination file and check return status
38 self.assertIsNone(tdb_copy(src_ldb_file, dst_ldb_file))
40 # Load copied file as LDB object
41 dst_ldb = Ldb(dst_ldb_file)
43 # Copmare contents of files
44 self.assertEqual(
45 src_ldb.searchone(basedn=ldb.Dn(src_ldb, "f=dc"), attribute="b"),
46 dst_ldb.searchone(basedn=ldb.Dn(dst_ldb, "f=dc"), attribute="b")
49 # Clean up
50 del src_ldb
51 del dst_ldb
52 os.unlink(src_ldb_file)
53 os.unlink(dst_ldb_file)