PEP8: add spaces after operators
[nivanova/samba-autobuild/.git] / python / samba / tests / samdb.py
1 # Unix SMB/CIFS implementation. Tests for SamDB
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
3 #
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.
8 #
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.
13 #
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/>.
16 #
17
18 """Tests for samba.samdb."""
19
20 import logging
21 import os
22 import uuid
23 import shutil
24
25 from samba.auth import system_session
26 from samba.provision import provision
27 from samba.tests import TestCaseInTempDir
28 from samba.dsdb import DS_DOMAIN_FUNCTION_2008_R2
29
30
31 class SamDBTestCase(TestCaseInTempDir):
32     """Base-class for tests with a Sam Database.
33
34     This is used by the Samba SamDB-tests, but e.g. also by the OpenChange
35     provisioning tests (which need a Sam).
36     """
37
38     def setUp(self):
39         super(SamDBTestCase, self).setUp()
40         self.session = system_session()
41         logger = logging.getLogger("selftest")
42         domain = "dsdb"
43         realm = "dsdb.samba.example.com"
44         host_name = "test"
45         server_role = "active directory domain controller"
46         dns_backend = "SAMBA_INTERNAL"
47         self.result = provision(logger,
48                                 self.session, targetdir=self.tempdir,
49                                 realm=realm, domain=domain,
50                                 hostname=host_name,
51                                 use_ntvfs=True,
52                                 serverrole=server_role,
53                                 dns_backend="SAMBA_INTERNAL",
54                                 dom_for_fun_level=DS_DOMAIN_FUNCTION_2008_R2)
55         self.samdb = self.result.samdb
56         self.lp = self.result.lp
57
58     def tearDown(self):
59         for f in ['names.tdb']:
60             os.remove(os.path.join(self.tempdir, f))
61
62         for d in ['etc', 'msg.lock', 'private', 'state', 'bind-dns']:
63             shutil.rmtree(os.path.join(self.tempdir, d))
64
65         super(SamDBTestCase, self).tearDown()