From 864218b6beebaeb337f14398f0544340ad30dd58 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 01:26:25 +0100 Subject: r26448: Add basic tests for param python module. (This used to be commit ccfab20dcc2d7059c402c03be244b759d59c4b81) --- source4/param/tests/bindings.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 source4/param/tests/bindings.py (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py new file mode 100644 index 0000000000..ea542e2187 --- /dev/null +++ b/source4/param/tests/bindings.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 2007 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import param +import unittest + +class LoadParmTestCase(unittest.TestCase): + def test_init(self): + file = param.LoadParm() + self.assertTrue(file is not None) + + def test_lenght(self): + file = param.LoadParm() + self.assertEquals(0, len(file)) + + +class ParamTestCase(unittest.TestCase): + def test_init(self): + file = param.ParamFile() + self.assertTrue(file is not None) + + def test_get_section(self): + file = param.ParamFile() + self.assertEquals(None, file.get_section("unknown")) + self.assertRaises(KeyError, lambda: file["unknown"]) -- cgit From a94142487add08cd38b6f51b7048c3b50eaef599 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 14 Dec 2007 14:28:21 +0100 Subject: r26456: Provide default config object, fix typo. (This used to be commit 2b59df2af973044d9d3875c9202c17647f561d3b) --- source4/param/tests/bindings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index ea542e2187..57ad23b21e 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -25,7 +25,7 @@ class LoadParmTestCase(unittest.TestCase): file = param.LoadParm() self.assertTrue(file is not None) - def test_lenght(self): + def test_length(self): file = param.LoadParm() self.assertEquals(0, len(file)) -- cgit From 32f439bfa458f7936b507cb5a1e3c74bcb8c68bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 11:12:36 +0100 Subject: r26503: Change order of arguments in param interface so it's easier to make the section name optional. Fix several smaller bits and pieces in the Python code. (This used to be commit 1b89311e5fa4fcde060df50e580dc221205cc8ca) --- source4/param/tests/bindings.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index 57ad23b21e..11f8a299be 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -35,6 +35,17 @@ class ParamTestCase(unittest.TestCase): file = param.ParamFile() self.assertTrue(file is not None) + def test_add_section(self): + file = param.ParamFile() + file.add_section("global") + self.assertTrue(file["global"] is not None) + + def test_set_param_string(self): + file = param.ParamFile() + file.add_section("global") + file["global"]["data"] = "bar" + self.assertEquals("bar", file["global"]["data"]) + def test_get_section(self): file = param.ParamFile() self.assertEquals(None, file.get_section("unknown")) -- cgit From f89c7a6e5eb082794d64b487e69fc442d138ca28 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 12:07:51 +0100 Subject: r26505: Add python bindings for some samdb-related functions, improve provisioning in python. (This used to be commit d2402251666738c0372bbbaeaa1d26c06e254033) --- source4/param/tests/bindings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index 11f8a299be..0bdd28a619 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -43,8 +43,8 @@ class ParamTestCase(unittest.TestCase): def test_set_param_string(self): file = param.ParamFile() file.add_section("global") - file["global"]["data"] = "bar" - self.assertEquals("bar", file["global"]["data"]) + file.set_string("data", "bar") + self.assertEquals("bar", file.get_string("data")) def test_get_section(self): file = param.ParamFile() -- cgit From 57b8a8fd42f5d89f439fd9d0781bd8f561a84131 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 23:16:12 +0100 Subject: r26517: Add functions for setting and getting parameters on a LoadParm. Pass loadparm context along to Ldb contexts. Other minor Python improvements. (This used to be commit 7a15b486bae8fb774058b2d94cc12b7b01ee6ac0) --- source4/param/tests/bindings.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index 0bdd28a619..9ea1c00daf 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -29,6 +29,23 @@ class LoadParmTestCase(unittest.TestCase): file = param.LoadParm() self.assertEquals(0, len(file)) + def test_set_workgroup(self): + file = param.LoadParm() + file.set("workgroup", "bla") + self.assertEquals("BLA", file.get("workgroup")) + + def test_is_mydomain(self): + file = param.LoadParm() + file.set("workgroup", "bla") + self.assertTrue(file.is_mydomain("BLA")) + self.assertFalse(file.is_mydomain("FOOBAR")) + + def test_is_myname(self): + file = param.LoadParm() + file.set("netbios name", "bla") + self.assertTrue(file.is_myname("BLA")) + self.assertFalse(file.is_myname("FOOBAR")) + class ParamTestCase(unittest.TestCase): def test_init(self): -- cgit From 00cb710fbc872cffa2d4d5c54c5ea65ba993da0c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 23 Jan 2008 23:15:39 +0100 Subject: Add bindings for lp_load_default(). (This used to be commit ffd793bbde636366855462f980f1f7d0e25afaab) --- source4/param/tests/bindings.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index 9ea1c00daf..0dd186b9df 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -46,6 +46,9 @@ class LoadParmTestCase(unittest.TestCase): self.assertTrue(file.is_myname("BLA")) self.assertFalse(file.is_myname("FOOBAR")) + def test_load_default(self): + file = param.LoadParm() + file.load_default() class ParamTestCase(unittest.TestCase): def test_init(self): -- cgit From 49706ab19bd3ffd6125639e6a7753b2350cf54e1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 23:59:34 +0200 Subject: Move more modules inside of the samba package. (This used to be commit 9b39e99f48266a54ed0b8890c2efde218b4b118a) --- source4/param/tests/bindings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param/tests/bindings.py') diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py index 0dd186b9df..d1d71e4485 100644 --- a/source4/param/tests/bindings.py +++ b/source4/param/tests/bindings.py @@ -17,7 +17,7 @@ # along with this program. If not, see . # -import param +from samba import param import unittest class LoadParmTestCase(unittest.TestCase): -- cgit