Browse Source

Select tests

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
043c4bee1c
  1. 4
      clusterview/opengl_widget.py
  2. 7
      clusterview/points.py
  3. 27
      tests/test_point_set.py

4
clusterview/opengl_widget.py

@ -307,10 +307,6 @@ def highlight_selection():
Given the current move bounding box, highlights any points inside it.
"""
# TODO: There's an edge case here
# The edge case is that if you click and drag up top_left becomes
# bottom right so there must be a condition where they should be
# swapped.
top_left = get_bb_top_left()
bottom_right = get_bb_bottom_right()

7
clusterview/points.py

@ -145,6 +145,13 @@ class PointSet:
def point_size(self):
return self.__point_size
def clear_selection(self):
"""
Handy helper function to clear all selected points.
"""
for p in self.__points:
p.unselect()
def add_point(self, x, y, attrs=[]):
"""
Adds a point in screen coordinates and an optional attribute to

27
tests/test_point_set.py

@ -83,3 +83,30 @@ def test_attributes_must_be_array_of_attributes():
with pytest.raises(ValueError):
l = PointSet(8)
l.add_point(1, 2, attrs=[1,2,3,4,5])
def test_clear_all_selected_points():
l = PointSet(8)
l.add_point(1, 2)
l.add_point(3, 4)
for p in l.points:
p.select()
selected = 0
for p in l.points:
if p.selected:
selected += 1
assert selected == 2
l.clear_selection()
unselected = 0
for p in l.points:
if not p.selected:
unselected += 1
assert unselected == 2

Loading…
Cancel
Save