def test_move_current_piece_down_should_reset_tick_counter(self): p = PlayerArea() p.current_piece = Piece(Piece.BLOCK_SHAPE) p.current_y = 0 p.current_x = p.INITIAL_X p.drop_counter = 5 p.handle_event(Event(KEYDOWN, { 'key': K_DOWN })) self.assertEqual(p.current_x, p.INITIAL_X) self.assertEqual(p.current_y, 1) self.assertEqual(p.drop_counter, p.ticks_per_drop)
def test_reset_the_counter_and_move_piece_down(self): p = PlayerArea() p.current_piece = Piece() p.drop_counter = 0 x_before = p.current_x y_before = p.current_y p.tick() self.assertEqual(p.drop_counter, p.ticks_per_drop) self.assertEqual(p.current_x, x_before) self.assertEqual(p.current_y, y_before + 1)
def test_attaching_piece_to_bottom_of_grid(self): p = PlayerArea() p.current_piece = Piece(Piece.BLOCK_SHAPE) p.current_y = 18 p.current_x = p.INITIAL_X p.drop_counter = 0 p.tick() self.assertIsNone(p.current_piece) for row in (18, 19): for col in (4, 5): index = (row * PlayerArea.GRID_COLUMNS) + col self.assertNotEqual(p.grid[index], 0)