Skip to content

Commit 55132a2

Browse files
committed
looser drag test
1 parent 67ae599 commit 55132a2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

tests/test_interactions.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,31 @@ def test_cyin001_dragging(dash_duo):
181181
dash_duo, init_x, init_y, 1, 1, elem_tap, actions
182182
)
183183

184+
def _test(newpos, expected_shift):
185+
dx, dy = expected_shift
186+
newx, newy = newpos
187+
expx = (dx / pixels_to_position_conv_factor) + init_node_x
188+
expy = (dy / pixels_to_position_conv_factor) + init_node_y
189+
assert abs(newx - expx) < 3
190+
assert abs(newy - expy) < 3
191+
184192
pixels_to_position_conv_factor = 1280 * 0.00085
185193
# Test dragging the nodes around
186-
assert perform_dragging(dash_duo, init_x, init_y, 150, 0, elem_tap, actions) == (
187-
round(150 / pixels_to_position_conv_factor) + init_node_x,
188-
0 + init_node_y,
194+
_test(
195+
perform_dragging(dash_duo, init_x, init_y, 150, 0, elem_tap, actions),
196+
(150, 0)
197+
)
198+
_test(
199+
perform_dragging(dash_duo, init_x + 150, init_y, 0, 150, elem_tap, actions),
200+
(150, 150)
189201
)
190-
assert perform_dragging(
191-
dash_duo, init_x + 150, init_y, 0, 150, elem_tap, actions
192-
) == (
193-
round(150 / pixels_to_position_conv_factor) + init_node_x,
194-
round(150 / pixels_to_position_conv_factor) + init_node_y,
202+
_test(
203+
perform_dragging(dash_duo, init_x + 150, init_y + 150, -150, -150, elem_tap, actions),
204+
(0, 0)
195205
)
196-
assert perform_dragging(
197-
dash_duo, init_x + 150, init_y + 150, -150, -150, elem_tap, actions
198-
) == (init_node_x, init_node_y)
199-
assert perform_dragging(dash_duo, init_x, init_y, 100, -100, elem_tap, actions) == (
200-
round(100 / pixels_to_position_conv_factor) + init_node_x,
201-
round(-100 / pixels_to_position_conv_factor) + init_node_y,
206+
_test(
207+
perform_dragging(dash_duo, init_x, init_y, 100, -100, elem_tap, actions),
208+
(100, -100)
202209
)
203210

204211

0 commit comments

Comments
 (0)