Add tests for upgrade of WINS database.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 9 Feb 2008 21:29:42 +0000 (22:29 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 9 Feb 2008 21:29:42 +0000 (22:29 +0100)
source/scripting/python/samba/tests/upgrade.py
source/scripting/python/samba/upgrade.py

index ddafa00691b79a380bf66adda49f69387b6dd0a6..4dc86ace8ad6edbb5024115ae5b5b64693d18891 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import samba.upgrade
-from unittest import TestCase
+from samba import Ldb
+from samba.upgrade import import_wins
+from samba.tests import LdbTestCase
 
 
+class WinsUpgradeTests(LdbTestCase):
+    def test_upgrade(self):
+        winsdb = {
+            "FOO#20": (200, ["127.0.0.1", "127.0.0.2"], 0x60)
+        }
+        import_wins(self.ldb, winsdb)
+
+        self.assertEquals(['name=FOO,type=0x20'], 
+                          [str(m.dn) for m in self.ldb.search(expression="(objectClass=winsRecord)")])
+
+    def test_version(self):
+        import_wins(self.ldb, {})
+        self.assertEquals("VERSION", 
+                self.ldb.search(expression="(objectClass=winsMaxVersion)")[0]["cn"])
index 8bf75d776e0fff9ebdcaa299b7b01c93214c43ad..01b62ff984050abf54b0b671b47d989803e24d97 100644 (file)
@@ -18,6 +18,7 @@ from samba import Ldb
 from samba.samdb import SamDB
 
 def import_sam_policy(samldb, samba3_policy, domaindn):
 from samba.samdb import SamDB
 
 def import_sam_policy(samldb, samba3_policy, domaindn):
+    """Import a Samba 3 policy database."""
     samldb.modify_ldif("""
 dn: %s
 changetype: modify
     samldb.modify_ldif("""
 dn: %s
 changetype: modify
@@ -201,7 +202,8 @@ def import_wins(samba4_winsdb, samba3_winsdb):
                            "versionID": str(version_id),
                            "address": ips})
 
                            "versionID": str(version_id),
                            "address": ips})
 
-    samba4_winsdb.add({"dn": "CN=VERSION",
+    samba4_winsdb.add({"dn": "cn=VERSION",
+                       "cn": "VERSION",
                        "objectClass": "winsMaxVersion",
                        "maxVersion": str(version_id)})
 
                        "objectClass": "winsMaxVersion",
                        "maxVersion": str(version_id)})