selftest.py: Add mk_realms_stanza function.
[ab/samba.git/.git] / selftest / tests / test_samba.py
1 # test_run.py -- Tests for selftest.target.samba
2 # Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; version 3
7 # of the License or (at your option) any later version of
8 # the License.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # MA  02110-1301, USA.
19
20 """Tests for selftest.target.samba."""
21
22 from selftest.tests import TestCase
23
24 from selftest.target.samba import (
25     bindir_path,
26     mk_realms_stanza,
27     )
28
29
30 class BinDirPathTests(TestCase):
31
32     def test_mapping(self):
33         self.assertEquals("exe4",
34             bindir_path({"exe": "exe4"}, "/some/path", "exe"))
35         self.assertEquals("/bin/ls",
36             bindir_path({"exe": "ls"}, "/bin", "exe"))
37
38     def test_no_mapping(self):
39         self.assertEqual("exe", bindir_path({}, "/some/path", "exe"))
40         self.assertEqual("/bin/ls",
41             bindir_path({}, "/bin", "ls"))
42
43
44 class MkRealmsStanzaTests(TestCase):
45
46     def test_basic(self):
47         self.assertEqual(
48            mk_realms_stanza("rijk", "dnsnaam", "domein", "ipv4_kdc"),
49           '''\
50  rijk = {
51   kdc = ipv4_kdc:88
52   admin_server = ipv4_kdc:88
53   default_domain = dnsnaam
54  }
55  dnsnaam = {
56   kdc = ipv4_kdc:88
57   admin_server = ipv4_kdc:88
58   default_domain = dnsnaam
59  }
60  domein = {
61   kdc = ipv4_kdc:88
62   admin_server = ipv4_kdc:88
63   default_domain = dnsnaam
64  }
65
66 ''')