def _cbTestReflector(self, parent):
        # create some child rows
        test_values = {}
        inserts = []
        child_values = {}
        for i in range(0, self.num_iterations):
            row = ChildRow()
            row.assignKeyAttr("childId", i)
            values = self.randomizeRow(row)
            values['test_key'] = row.test_key = "first"
            child_values[i] = values
            inserts.append(self.reflector.insertRow(row))
            row = None
        #del inserts
        d = defer.gatherResults(inserts)
        values = [None]

        def _loadObjects(_):
            d = self.reflector.loadObjectsFrom(childTableName, parentRow=parent)
            return d.addCallback(self.gotData)

        def _checkLoadObjects(_):
            self.failUnless(len(self.data) == self.num_iterations,
                            "no rows on query")
            self.failUnless(len(parent.childRows) == self.num_iterations,
                            "did not load child rows: %d" % len(parent.childRows))
            for child in parent.childRows:
                self.failUnless(rowMatches(child, child_values[child.childId]),
                                "child %d does not match" % child.childId)

        def _checkLoadObjects2(_):
            self.failUnless(len(self.data) == self.num_iterations,
                            "no rows on query")
            self.failUnless(len(parent.childRows) == self.num_iterations,
                            "child rows added twice!: %d" % len(parent.childRows))

        def _changeParent(_):
            # now change the parent
            values[0] = self.randomizeRow(parent)
            return self.reflector.updateRow(parent)

        def _loadBack(_):
            # now load it back in
            whereClause = [("key_string", EQUAL, "first")]
            d = self.reflector.loadObjectsFrom(tableName, whereClause=whereClause)
            return d.addCallback(self.gotData)

        def _checkLoadBack(_):
            # make sure it came back as what we saved
            self.failUnless(len(self.data) == 1, "no row")
            parent = self.data[0]
            self.failUnless(rowMatches(parent, values[0]), "no match")
            # save parent
            test_values[parent.key_string] = values[0]
            parent = None

        def _saveMoreTestRows(_):
            # save some more test rows
            ds = []
            for i in range(0, self.num_iterations):
                row = TestRow()
                row.assignKeyAttr("key_string", i%"bulk%d")
                test_values[row.key_string] = self.randomizeRow(row)
                ds.append(self.reflector.insertRow(row))
            return defer.gatherResults(ds)

        def _loadRowsBack(_):
            # now load them all back in
            d = self.reflector.loadObjectsFrom("testTable")
            return d.addCallback(self.gotData)

        def _checkRowsBack(_):
            # make sure they are the same
            self.failUnless(len(self.data) == self.num_iterations + 1,
                            "query did not get rows")
            for row in self.data:
                self.failUnless(rowMatches(row, test_values[row.key_string]),
                                "child %s does not match" % row.key_string)

        def _changeRows(_):
            # now change them all
            ds = []
            for row in self.data:
                test_values[row.key_string] = self.randomizeRow(row)
                ds.append(self.reflector.updateRow(row))
            d = defer.gatherResults(ds)
            return d.addCallback(_cbChangeRows)

        def _cbChangeRows(_):
            self.data = None

        def _deleteRows(_):
            # now delete them
            ds = []
            for row in self.data:
                ds.append(self.reflector.deleteRow(row))
            d = defer.gatherResults(ds)
            return d.addCallback(_cbChangeRows)

        def _checkRowsDeleted(_):
            self.failUnless(len(self.data) == 0, "rows were not deleted")

        d.addCallback(_loadObjects)
        d.addCallback(_checkLoadObjects)
        d.addCallback(_loadObjects)
        d.addCallback(_checkLoadObjects2)
        d.addCallback(_changeParent)
        d.addCallback(_loadBack)
        d.addCallback(_checkLoadBack)
        d.addCallback(_saveMoreTestRows)
        d.addCallback(_loadRowsBack)
        d.addCallback(_checkRowsBack)
        d.addCallback(_changeRows)
        d.addCallback(_loadRowsBack)
        d.addCallback(_checkRowsBack)
        d.addCallback(_deleteRows)
        d.addCallback(_loadRowsBack)
        d.addCallback(_checkRowsDeleted)
        return d
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_reflector.py/ReflectorTestBase._cbTestReflector/swapped operands of `%`