d1d71e4485e50b1fd8aba6ea8525ba59f1cc2b4e
[metze/samba/wip.git] / source4 / param / tests / bindings.py
1 #!/usr/bin/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 from samba import param
21 import unittest
22
23 class LoadParmTestCase(unittest.TestCase):
24     def test_init(self):
25         file = param.LoadParm()
26         self.assertTrue(file is not None)
27
28     def test_length(self):
29         file = param.LoadParm()
30         self.assertEquals(0, len(file))
31
32     def test_set_workgroup(self):
33         file = param.LoadParm()
34         file.set("workgroup", "bla")
35         self.assertEquals("BLA", file.get("workgroup"))
36
37     def test_is_mydomain(self):
38         file = param.LoadParm()
39         file.set("workgroup", "bla")
40         self.assertTrue(file.is_mydomain("BLA"))
41         self.assertFalse(file.is_mydomain("FOOBAR"))
42
43     def test_is_myname(self):
44         file = param.LoadParm()
45         file.set("netbios name", "bla")
46         self.assertTrue(file.is_myname("BLA"))
47         self.assertFalse(file.is_myname("FOOBAR"))
48
49     def test_load_default(self):
50         file = param.LoadParm()
51         file.load_default()
52
53 class ParamTestCase(unittest.TestCase):
54     def test_init(self):
55         file = param.ParamFile()
56         self.assertTrue(file is not None)
57
58     def test_add_section(self):
59         file = param.ParamFile()
60         file.add_section("global")
61         self.assertTrue(file["global"] is not None)
62
63     def test_set_param_string(self):
64         file = param.ParamFile()
65         file.add_section("global")
66         file.set_string("data", "bar")
67         self.assertEquals("bar", file.get_string("data"))
68
69     def test_get_section(self):
70         file = param.ParamFile()
71         self.assertEquals(None, file.get_section("unknown"))
72         self.assertRaises(KeyError, lambda: file["unknown"])