KCC: add tests for kcc.graph repltimes functions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 5 May 2015 23:20:28 +0000 (11:20 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 12 Jun 2015 04:57:15 +0000 (06:57 +0200)
There used to be bugs in these.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/kcc/graph.py
selftest/tests.py

index e43667fc3558bc64b0bb8f084b89abe639db4744..dec861a9de579baad4239148a44836559e94cd05 100644 (file)
@@ -25,9 +25,27 @@ from samba.kcc.graph import *
 
 import itertools
 
-class GraphFunctionTests(samba.tests.TestCase):
+
+def ntdsconn_schedule(times):
+    if times is None:
+        return None
+    from samba.dcerpc import drsblobs
+    schedule = drsblobs.schedule()
+    schedule.size = 188
+    schedule.bandwidth = 0
+    schedule.numberOfSchedules = 1
+    header = drsblobs.scheduleHeader()
+    header.type = 0
+    header.offset = 20
+    schedule.headerArray = [header]
+    data = drsblobs.scheduleSlots()
+    data.slots = times
+    schedule.dataArray = [data]
+    return schedule
 
 
+class GraphFunctionTests(samba.tests.TestCase):
+
     def test_total_schedule(self):
         schedule = [0x81] * 84
         for schedule, total in (
@@ -35,5 +53,18 @@ class GraphFunctionTests(samba.tests.TestCase):
                 ([0xff] * 84, 84 * 8),
                 ([0xaa] * 84, 84 * 4),
                 ([0x03, 0x33] * 42, 42 * 6),
-                (range(4) * 21, 21 * 5)):
-            self.assetEquals(total_schedule(schedule), total)
+                (range(7) * 12, 12 * 9),
+                (range(4) * 21, 21 * 4)):
+            self.assertEquals(total_schedule(schedule), total)
+
+    def test_convert_schedule_to_repltimes(self):
+        for ntdsconn_times, repltimes in (
+                ([0x01] * 168, [0x11] * 84),
+                (None, [0x11] * 84),
+                ([0x06] * 168, [0x66] * 84),
+                ([0x03, 0xa] * 84, [0x3a] * 84),
+                (range(7) * 24,
+                 [0x01, 0x23, 0x45, 0x60, 0x12, 0x34, 0x56] * 12)):
+            schedule = ntdsconn_schedule(ntdsconn_times)
+            self.assertEquals(convert_schedule_to_repltimes(schedule),
+                              repltimes)
index 723909479495026a92d5d0a3d99703c96321ccf5..ef2f6a4bc0b5b2e81edcef5b392dff216b22f630 100644 (file)
@@ -96,6 +96,7 @@ planpythontestsuite("none", "samba.tests.upgradeprovision")
 planpythontestsuite("none", "samba.tests.xattr")
 planpythontestsuite("none", "samba.tests.ntacls")
 planpythontestsuite("none", "samba.tests.policy")
+planpythontestsuite("none", "samba.tests.kcc.graph")
 planpythontestsuite("none", "samba.tests.kcc.graph_utils")
 planpythontestsuite("none", "samba.tests.kcc.kcc_utils")
 planpythontestsuite("none", "samba.tests.kcc.ldif_import_export")