def test_find_corner_squares_3x3(self): piece = Blockies.Piece('square', 3, 3, (3, 3), const.WHITE) expected_squares = [(3, 3), (4, 3), (5, 3), (3, 4), (4, 4), (5, 4), (3, 5), (4, 5), (5, 5)] expected_corners = [(3, 3), (3, 5), (5, 5), (5, 3)] self.assertEqual(piece.squares, expected_squares) self.assertEqual(Blockies.find_corners(piece.squares), expected_corners)
def test_rotate_3_2_rect_clockwise(self): piece = Blockies.Piece('rectangle', 3, 2, (2, 2), const.WHITE) initial_squares = [(2, 2), (3, 2), (4, 2), (2, 3), (3, 3), (4, 3)] expected_squares = [(1, 2), (2, 2), (1, 3), (2, 3), (1, 4), (2, 4)] self.assertEqual(set(piece.squares), set(initial_squares)) piece.rotate_clockwise() self.assertEqual(set(piece.squares), set(expected_squares), 'rotated 3x2 rect does not occupy expected squares')
def test_rotate_1_2_rect_clockwise(self): piece = Blockies.Piece('rectangle', 1, 2, (3, 6), const.WHITE) initial_squares = [(3, 6), (3, 7)] expected_squares = [(2, 6), (3, 6)] self.assertEqual(set(piece.squares), set(initial_squares)) piece.rotate_clockwise() self.assertEqual(set(piece.squares), set(expected_squares), 'rotated 1x2 rect does not occupy expected squares')
def make_empty_game_grid(self): return Blockies.Game(2)
def test_unique_from_list(self): ordered_list = [1, "Hello", (3, 3), "Hello", (1, 1), (3, 3)] self.assertEqual(Blockies.unique_from_list(ordered_list), [1, "Hello", (3, 3), (1, 1)])
def test_shift_coords_positive_xy(self): negative_coords = [(-1, -1), (0, -1), (-1, 0), (0, 0)] expected_coords = [(0, 0), (1, 0), (0, 1), (1, 1)] self.assertEqual(Blockies.shift_coords_positive(negative_coords), expected_coords)