Taylor Bockman
5 years ago
8 changed files with 179 additions and 147 deletions
@ -0,0 +1,17 @@
|
||||
from enum import Enum |
||||
|
||||
|
||||
class Color(str, Enum): |
||||
BLUE = 'BLUE' |
||||
BLACK = 'BLACK' |
||||
GREY = 'GREY' |
||||
|
||||
|
||||
# A simple map from Color -> RGBA 4-Tuple |
||||
# Note: The color values in the tuple are not RGB, but |
||||
# rather OpenGL percentage values for RGB. |
||||
COLOR_TO_RGBA = { |
||||
Color.GREY: (0.827, 0.827, 0.826, 0.0), |
||||
Color.BLUE: (0.118, 0.565, 1.0, 0.0), |
||||
Color.BLACK: (0.0, 0.0, 0.0, 0.0) |
||||
} |
@ -1,42 +1,49 @@
|
||||
import pytest |
||||
|
||||
from clusterview.colors import Color |
||||
from clusterview.exceptions import ExceededWindowBoundsError |
||||
from clusterview.points import Point, PointSet |
||||
|
||||
|
||||
def test_move_point(): |
||||
# The minimum starting position is 1/2 point away |
||||
# from the edges |
||||
p = Point(4, 4, 8, 100, 100) |
||||
p = Point(4, 4, Color.GREY, 8, 100, 100) |
||||
|
||||
p.move(1, 1) |
||||
|
||||
assert p.x == 5 and p.y == 5 |
||||
|
||||
|
||||
def test_attributes_must_be_array_of_attributes(): |
||||
with pytest.raises(ValueError): |
||||
l = PointSet(8, 100, 100) |
||||
l.add_point(4, 4, attrs=[1,2,3,4,5]) |
||||
point_set = PointSet(8, 100, 100) |
||||
point_set.add_point(4, 4, Color.GREY, attrs=[1, 2, 3, 4, 5]) |
||||
|
||||
|
||||
def test_move_point_outside_screen_x_positive(): |
||||
p = Point(4, 4, 8, 100, 100) |
||||
pt = Point(4, 4, Color.GREY, 8, 100, 100) |
||||
|
||||
with pytest.raises(ExceededWindowBoundsError): |
||||
pt.move(96, 0) |
||||
|
||||
with pytest.raises(ExceededWindowBoundsError) as exc_info: |
||||
p.move(96, 0) |
||||
|
||||
def test_move_point_outside_screen_y_positive(): |
||||
p = Point(4, 4, 8, 100, 100) |
||||
p = Point(4, 4, Color.GREY, 8, 100, 100) |
||||
|
||||
with pytest.raises(ExceededWindowBoundsError): |
||||
p.move(0, 95) |
||||
|
||||
|
||||
def test_move_point_outside_screen_x_negative(): |
||||
p = Point(4, 4, 8, 100, 100) |
||||
p = Point(4, 4, Color.GREY, 8, 100, 100) |
||||
|
||||
with pytest.raises(ExceededWindowBoundsError): |
||||
p.move(-5, 0) |
||||
|
||||
|
||||
def test_move_point_outside_screen_y_negative(): |
||||
p = Point(4, 4, 8, 100, 100) |
||||
p = Point(4, 4, Color.GREY, 8, 100, 100) |
||||
|
||||
with pytest.raises(ExceededWindowBoundsError): |
||||
p.move(0, -5) |
||||
|
Loading…
Reference in new issue