def test_invalid_rotations(): """cannot rotate blocks if they will collide with another""" field = Field.from_str('0,0,0,0;0,0,0,0;0,0,0,2;0,0,0,2;0,0,0,2;0,0,0,2') # Vertical I blocks placed next to each other block = IBlock(field).rotate_cw() block.position = 0, 2 assert str(field) == '0,0,0,0;0,0,0,0;0,0,1,2;0,0,1,2;0,0,1,2;0,0,1,2' # Block unable to rotate from this position with pytest.raises(InvalidBlockRotation): block.rotate_ccw() assert str(field) == '0,0,0,0;0,0,0,0;0,0,1,2;0,0,1,2;0,0,1,2;0,0,1,2'
def test_i_block(): field = Field(6, 4) block = IBlock(field) block.position = 0, -1 assert str(field) == '1,1,1,1;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0' block.rotate_ccw() assert str(field) == '0,1,0,0;0,1,0,0;0,1,0,0;0,0,0,0;0,0,0,0;0,0,0,0' block.rotate_cw().rotate_cw() assert str(field) == '0,0,1,0;0,0,1,0;0,0,1,0;0,0,0,0;0,0,0,0;0,0,0,0' block.position = 1, 2 assert str(field) == '0,0,0,0;0,0,0,0;0,0,0,1;0,0,0,1;0,0,0,1;0,0,0,1'