97926850d2dc8c68b8ec5d6ca8a05f2ee6bcf347
[rusty/samba.git] / source4 / scripting / python / samba / tests / registry.py
1 #!/usr/bin/env python
2
3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5 #   
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #   
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #   
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 """Tests for samba.registry."""
21
22 import os
23 from samba import registry
24 import samba.tests
25
26 class HelperTests(samba.tests.TestCase):
27
28     def test_predef_to_name(self):
29         self.assertEquals("HKEY_LOCAL_MACHINE", 
30                           registry.get_predef_name(0x80000002))
31
32     def test_str_regtype(self):
33         self.assertEquals("REG_DWORD", registry.str_regtype(4))
34
35
36
37 class HiveTests(samba.tests.TestCaseInTempDir):
38
39     def setUp(self):
40         super(HiveTests, self).setUp()
41         self.hive_path = os.path.join(self.tempdir, "ldb_new.ldb")
42         self.hive = registry.open_ldb(self.hive_path)
43
44     def tearDown(self):
45         del self.hive
46         os.unlink(self.hive_path)
47         super(HiveTests, self).tearDown()
48
49     def test_ldb_new(self):
50         self.assertTrue(self.hive is not None)
51
52     #def test_flush(self):
53     #    self.hive.flush()
54
55     #def test_del_value(self):
56     #    self.hive.del_value("FOO")
57
58
59 class RegistryTests(samba.tests.TestCase):
60
61     def test_new(self):
62         self.registry = registry.Registry()