devtools/testlib.py
branchstable
changeset 3689 deb13e88e037
parent 3226 10f4f525044c
child 3720 5376aaadd16b
child 3764 034aa14b740a
equal deleted inserted replaced
3688:421fb447ecb2 3689:deb13e88e037
    42     cardinality
    42     cardinality
    43     """
    43     """
    44     # compute how many entities by type we need to be able to satisfy relation constraint
    44     # compute how many entities by type we need to be able to satisfy relation constraint
    45     relmap = {}
    45     relmap = {}
    46     for rschema in schema.relations():
    46     for rschema in schema.relations():
    47         if rschema.is_final():
    47         if rschema.final:
    48             continue
    48             continue
    49         for subj, obj in rschema.iter_rdefs():
    49         for subj, obj in rschema.iter_rdefs():
    50             card = rschema.rproperty(subj, obj, 'cardinality')
    50             card = rschema.rproperty(subj, obj, 'cardinality')
    51             if card[0] in '1?' and len(rschema.subjects(obj)) == 1:
    51             if card[0] in '1?' and len(rschema.subjects(obj)) == 1:
    52                 relmap.setdefault((rschema, subj), []).append(str(obj))
    52                 relmap.setdefault((rschema, subj), []).append(str(obj))
   141             rset = cu.execute('%s X' % etype)
   141             rset = cu.execute('%s X' % etype)
   142             edict[str(etype)] = set(row[0] for row in rset.rows)
   142             edict[str(etype)] = set(row[0] for row in rset.rows)
   143         existingrels = {}
   143         existingrels = {}
   144         ignored_relations = SYSTEM_RELATIONS + self.ignored_relations
   144         ignored_relations = SYSTEM_RELATIONS + self.ignored_relations
   145         for rschema in self.schema.relations():
   145         for rschema in self.schema.relations():
   146             if rschema.is_final() or rschema in ignored_relations:
   146             if rschema.final or rschema in ignored_relations:
   147                 continue
   147                 continue
   148             rset = cu.execute('DISTINCT Any X,Y WHERE X %s Y' % rschema)
   148             rset = cu.execute('DISTINCT Any X,Y WHERE X %s Y' % rschema)
   149             existingrels.setdefault(rschema.type, set()).update((x, y) for x, y in rset)
   149             existingrels.setdefault(rschema.type, set()).update((x, y) for x, y in rset)
   150         q = make_relations_queries(self.schema, edict, cu, ignored_relations,
   150         q = make_relations_queries(self.schema, edict, cu, ignored_relations,
   151                                    existingrels=existingrels)
   151                                    existingrels=existingrels)