selftest: skip the samba4.smb2.compound testsuite
[Samba/gebeck_regimport.git] / buildtools / wafsamba / tests / test_utils.py
bloba9578e25ae6b8739f818576182e4912b352221b5
1 # Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU Lesser General Public License as published by
5 # the Free Software Foundation; either version 2.1 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 from wafsamba.tests import TestCase
19 from wafsamba.samba_utils import (
20 TO_LIST,
21 dict_concat,
22 subst_vars_error,
23 unique_list,
26 class ToListTests(TestCase):
28 def test_none(self):
29 self.assertEquals([], TO_LIST(None))
31 def test_already_list(self):
32 self.assertEquals(["foo", "bar", 1], TO_LIST(["foo", "bar", 1]))
34 def test_default_delimiter(self):
35 self.assertEquals(["foo", "bar"], TO_LIST("foo bar"))
36 self.assertEquals(["foo", "bar"], TO_LIST(" foo bar "))
37 self.assertEquals(["foo ", "bar"], TO_LIST(" \"foo \" bar "))
39 def test_delimiter(self):
40 self.assertEquals(["foo", "bar"], TO_LIST("foo,bar", ","))
41 self.assertEquals([" foo", "bar "], TO_LIST(" foo,bar ", ","))
42 self.assertEquals([" \" foo\"", " bar "], TO_LIST(" \" foo\", bar ", ","))
45 class UniqueListTests(TestCase):
47 def test_unique_list(self):
48 self.assertEquals(["foo", "bar"], unique_list(["foo", "bar", "foo"]))
51 class SubstVarsErrorTests(TestCase):
53 def test_valid(self):
54 self.assertEquals("", subst_vars_error("", {}))
55 self.assertEquals("FOO bar", subst_vars_error("${F} bar", {"F": "FOO"}))
57 def test_invalid(self):
58 self.assertRaises(KeyError, subst_vars_error, "${F}", {})
61 class DictConcatTests(TestCase):
63 def test_empty(self):
64 ret = {}
65 dict_concat(ret, {})
66 self.assertEquals({}, ret)
68 def test_same(self):
69 ret = {"foo": "bar"}
70 dict_concat(ret, {"foo": "bla"})
71 self.assertEquals({"foo": "bar"}, ret)
73 def test_simple(self):
74 ret = {"foo": "bar"}
75 dict_concat(ret, {"blie": "bla"})
76 self.assertEquals({"foo": "bar", "blie": "bla"}, ret)