Skip to content

Commit

Permalink
fix problematic test
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCaha committed Jan 18, 2025
1 parent 0b0c9ba commit 09d80c7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/gui/test_point_capture_map_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,28 @@ def test_point_capture_map_tool_no_snap(

def test_point_capture_map_tool_with_snap(
qgis_canvas: QgsMapCanvas,
layer_polygons: QgsVectorLayer,
layer_points: QgsVectorLayer,
qtbot: QtBot,
):

setup_project_with_snapping(qgis_canvas, layer_polygons)
setup_project_with_snapping(qgis_canvas, layer_points, 15)

map_tool = PointCaptureMapTool(qgis_canvas)

point = QgsPointXY(-336433.464, -1189082.192)
layer_point = layer_points.getFeature(1).geometry().asPoint()
assert layer_point

offset_by = 5
point = QgsPointXY(layer_point.x() - offset_by, layer_point.y() + offset_by)

map_tool.canvasMoveEvent(create_mouse_event(qgis_canvas, point, event_type=QEvent.Type.MouseMove))

assert map_tool.get_point() == QgsPointXY(-336430.54888639913406223, -1189081.19254285283386707)
assert map_tool.get_point() == layer_point
assert map_tool.get_point() != point

with qtbot.waitSignal(map_tool.canvasClicked, timeout=None, raising=True):
map_tool.canvasReleaseEvent(create_mouse_event(qgis_canvas, point))

assert map_tool.is_point_snapped()
assert map_tool.snap_layer() == layer_polygons.name()
assert map_tool.get_point() == QgsPointXY(-336430.54888639913406223, -1189081.19254285283386707)
assert map_tool.snap_layer() == layer_points.name()
assert map_tool.get_point() == layer_point

0 comments on commit 09d80c7

Please sign in to comment.