expand tabs in python file, consistent with the rest of the file.
[amitay/samba.git] / source4 / scripting / python / samba / tests / __init__.py
index 5e1ff87c2b51d94c1dc37987705b96feab5cbfda..b342b93c498d008f25f7ca7b7287af31ec5bc595 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 # Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
 #   
 # 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
@@ -17,6 +17,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+"""Samba Python tests."""
+
 import os
 import ldb
 import samba
@@ -24,11 +26,13 @@ import tempfile
 import unittest
 
 class LdbTestCase(unittest.TestCase):
+    """Trivial test case for running tests against a LDB."""
     def setUp(self):
         self.filename = os.tempnam()
         self.ldb = samba.Ldb(self.filename)
 
     def set_modules(self, modules=[]):
+        """Change the modules for this Ldb."""
         m = ldb.Message()
         m.dn = ldb.Dn(self.ldb, "@MODULES")
         m["@LIST"] = ",".join(modules)
@@ -43,6 +47,7 @@ class TestCaseInTempDir(unittest.TestCase):
 
     def tearDown(self):
         super(TestCaseInTempDir, self).tearDown()
+        self.assertEquals([], os.listdir(self.tempdir))
         os.rmdir(self.tempdir)
 
 
@@ -63,6 +68,10 @@ class SubstituteVarTestCase(unittest.TestCase):
     def test_unknown_var(self):
         self.assertEquals("foo ${bla} gsff", 
                 samba.substitute_var("foo ${bla} gsff", {"bar": "bla"}))
+                
+    def test_check_all_substituted(self):
+        samba.check_all_substituted("nothing to see here")
+        self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}")
 
 
 class LdbExtensionTests(TestCaseInTempDir):
@@ -71,8 +80,19 @@ class LdbExtensionTests(TestCaseInTempDir):
         l = samba.Ldb(path)
         try:
             l.add({"dn": "foo=dc", "bar": "bla"})
-            self.assertEquals("bla", l.searchone(ldb.Dn(l, "foo=dc"), "bar"))
+            self.assertEquals("bla", l.searchone(basedn=ldb.Dn(l, "foo=dc"), attribute="bar"))
         finally:
             del l
             os.unlink(path)
 
+
+cmdline_loadparm = None
+cmdline_credentials = None
+
+class RpcInterfaceTestCase(unittest.TestCase):
+    def get_loadparm(self):
+        assert cmdline_loadparm is not None
+        return cmdline_loadparm
+
+    def get_credentials(self):
+        return cmdline_credentials