def test_make_candidates_data(): r1 = R(5, 5, 10, 30) cloud = RectangleCloud([r1]) ## Make a spot facing down to infinity, i.e. without intersection occ = cloud.get_occupied_rect() spot = R(occ.x - INF, occ.y - INF, occ.w + 2 * INF, INF) intsec = occ.get_intersection(spot) assert not intsec rect = R(0, 0, 10, 10) data = cloud.make_candidates_data(spot, rect) cand = R(5, -5, 10, 10) assert data == [(cand, intsec, spot)] ## test intersecting spot r2 = R(15, 20, 10, 10) cloud._rects.append(r2) cloud._invalidate() occ = cloud.get_occupied_rect() spot = R(r1.x + r1.w, r2.y + r2.h, occ.x + occ.w - (r2.x + r2.w) + INF, \ occ.y + occ.h - (r2.y + r2.h) + INF) intsec = occ.get_intersection(spot) assert intsec data = cloud.make_candidates_data(spot, rect) cand = R(spot.x, spot.y, rect.w, rect.h) assert data == [(cand, intsec, spot)]