Move python modules from source4/scripting/python/ to python/.
[samba.git] / python / samba / tests / param.py
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
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.param."""
19
20 from samba import param
21 import samba.tests
22
23 class LoadParmTestCase(samba.tests.TestCase):
24
25     def test_init(self):
26         file = param.LoadParm()
27         self.assertTrue(file is not None)
28
29     def test_length(self):
30         file = param.LoadParm()
31         self.assertEquals(0, len(file))
32
33     def test_set_workgroup(self):
34         file = param.LoadParm()
35         file.set("workgroup", "bla")
36         self.assertEquals("BLA", file.get("workgroup"))
37
38     def test_is_mydomain(self):
39         file = param.LoadParm()
40         file.set("workgroup", "bla")
41         self.assertTrue(file.is_mydomain("BLA"))
42         self.assertFalse(file.is_mydomain("FOOBAR"))
43
44     def test_is_myname(self):
45         file = param.LoadParm()
46         file.set("netbios name", "bla")
47         self.assertTrue(file.is_myname("BLA"))
48         self.assertFalse(file.is_myname("FOOBAR"))
49
50     def test_load_default(self):
51         file = param.LoadParm()
52         file.load_default()
53
54     def test_section_nonexistent(self):
55         samba_lp = param.LoadParm()
56         samba_lp.load_default()
57         self.assertRaises(KeyError, samba_lp.__getitem__, "nonexistent")