s4/test: schemaInfo may not to be set yet
authorKamen Mazdrashki <kamenim@samba.org>
Thu, 22 Apr 2010 01:39:04 +0000 (04:39 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Thu, 29 Apr 2010 01:54:05 +0000 (04:54 +0300)
On newly provisioned Forest schemaInfo is not initially set.
It should be created after firs Schema modification

source4/lib/ldb/tests/python/dsdb_schema_info.py

index 5fd0ccb73af5af26ee7e10b887f6389380207abc..f0c8c14d6d257a261315ca63aa58fb073c4fbd23 100755 (executable)
@@ -62,18 +62,26 @@ class SchemaInfoTestCase(samba.tests.RpcInterfaceTestCase):
         # get DC invocation_id
         self.invocation_id = GUID(ldb.get_invocation_id())
 
+
     def tearDown(self):
         super(SchemaInfoTestCase, self).tearDown()
 
 
     def _getSchemaInfo(self):
-        schema_info_data = ldb.searchone(attribute="schemaInfo",
-                                         basedn=self.schema_dn,
-                                         expression="(objectClass=*)",
-                                         scope=SCOPE_BASE)
-        self.assertEqual(len(schema_info_data), 21)
-        schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
-        self.assertEqual(schema_info.marker, 0xFF)
+        try:
+            schema_info_data = ldb.searchone(attribute="schemaInfo",
+                                             basedn=self.schema_dn,
+                                             expression="(objectClass=*)",
+                                             scope=SCOPE_BASE)
+            self.assertEqual(len(schema_info_data), 21)
+            schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
+            self.assertEqual(schema_info.marker, 0xFF)
+        except KeyError:
+            # create default schemaInfo if
+            # attribute value is not created yet
+            schema_info = schemaInfoBlob()
+            schema_info.revision = 0
+            schema_info.invocation_id = self.invocation_id
         return schema_info
 
     def _checkSchemaInfo(self, schi_before, schi_after):