def test_covered_by(self): l = session.query(Lake).filter(Lake.lake_name=='Lake Blue').one() p1 = session.query(Spot).filter(Spot.spot_height==102.34).one() p2 = session.query(Spot).filter(Spot.spot_height==388.62).one() covered_spots = session.query(Spot).filter(Spot.spot_location.covered_by(l.lake_geom)).all() ok_(session.scalar(p1.spot_location.covered_by(l.lake_geom))) ok_(not session.scalar(p2.spot_location.covered_by(l.lake_geom))) ok_(p1 in covered_spots) ok_(p2 not in covered_spots) eq_(session.scalar(functions.covered_by('LINESTRING(0 1, 2 1)', 'POLYGON((-1 -1, 3 -1, 3 2, -1 2, -1 -1))')), True)