def test_indirect_connection(self):
     self.assertEqual(
         has_path({
             'A': ['B'],
             'B': ['A', 'C'],
             'C': ['B']
         }, 'A', 'C'), ['B', 'C'])
Esempio n. 2
0
 def keep_var(self, varname):
     if varname in 'SO':
         return varname in self.existingvars
     if varname == 'U':
         return True
     vargraph = self.current_expr.vargraph
     for existingvar in self.existingvars:
         if varname not in vargraph or has_path(vargraph, varname, existingvar):
             return True
     # no path from this variable to an existing variable
     return False
Esempio n. 3
0
 def has_unique_value_path(self, select, fromvar, tovar):
     graph = select.vargraph
     path = has_path(graph, fromvar, tovar)
     if path is None:
         return False
     for var in path:
         try:
             rtype = graph[(fromvar, var)]
             cardidx = 0
         except KeyError:
             rtype = graph[(var, fromvar)]
             cardidx = 1
         rschema = self.schema.rschema(rtype)
         for rdef in rschema.rdefs.values():
             # XXX aggregats handling needs much probably some enhancements...
             if not (var in select.aggregated or
                     (rdef.cardinality[cardidx] in '?1' and
                      (var == tovar or not rschema.final))):
                 return False
         fromvar = var
     return True
 def test_cycle(self):
     self.assertEqual(has_path({'A': ['A']}, 'A', 'B'), None)
 def test_no_connection(self):
     self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'C'), None)
Esempio n. 6
0
 def test_direct_connection(self):
     self.assertEquals(has_path({'A': ['B'], 'B': ['A']}, 'A', 'B'), ['B'])
Esempio n. 7
0
 def test_cycle(self):
     self.assertEqual(has_path({'A': ['A']}, 'A', 'B'), None)
Esempio n. 8
0
 def test_no_connection(self):
     self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'C'), None)
Esempio n. 9
0
 def test_indirect_connection(self):
     self.assertEqual(has_path({'A': ['B'], 'B': ['A', 'C'], 'C': ['B']}, 'A', 'C'), ['B', 'C'])
Esempio n. 10
0
 def test_direct_connection(self):
     self.assertEquals(has_path({'A': ['B'], 'B': ['A']}, 'A', 'B'), ['B'])