def test_stroke_inequality():
    stroke1 = planner.Stroke(action=planner.MOVE,
                             end=planner.Pixel(0, 0),
                             oldcolor=0,
                             newcolor=0)
    stroke2 = planner.Stroke(action=planner.MOVE,
                             end=planner.Pixel(1, 1),
                             oldcolor=0,
                             newcolor=0)
    assert stroke1 != stroke2
def stroke_stack():
    start = planner.Pixel(0, 0)
    current = planner.Stroke(
        action=planner.
        INIT,  # I think this is a garbage value that will be overwritten
        end=start,
        oldcolor=0,
        newcolor=0)
    return planner.StrokeStack(current)
def test_stroke_switch_brush_output():
    end = planner.Pixel(0, 1)
    oldcolor = 10
    newcolor = 20
    stroke = planner.Stroke(action=planner.SWITCH_BRUSH,
                            end=end,
                            oldcolor=oldcolor,
                            newcolor=newcolor)
    assert stroke.output() == "-5 1 0 10 20\n"
def test_stroke_move_output():
    end = planner.Pixel(0, 1)
    oldcolor = 10
    newcolor = 20
    stroke = planner.Stroke(action=planner.MOVE,
                            end=end,
                            oldcolor=oldcolor,
                            newcolor=newcolor)
    assert stroke.output() == "-1 1 0\n"
def test_stroke_stack_color():
    start = planner.Pixel(0, 0)
    current = planner.Stroke(
        action=planner.
        INIT,  # I think this is a garbage value that will be overwritten
        end=start,
        oldcolor=0,
        newcolor=0)
    strokes = planner.StrokeStack(current)
    strokes.push_instruction(action=planner.SWITCH_BRUSH, newcolor=1)
    strokes.push_instruction(action=planner.MOVE)
    assert strokes.peek().oldcolor == 1
def test_left_right_stroke(stroke_stack):
    """ Should create a stroke going across the patch. """
    init_stroke = stroke_stack.peek()
    tank = planner.Tank()
    patch = [planner.Pixel(0, 0), planner.Pixel(0, 1), planner.Pixel(0, 2)]
    planner.left_right_stroke(patch, stroke_stack, tank, newpatch=False)
    assert stroke_stack.strokes == [
        init_stroke,
        planner.Stroke(action=planner.MOVE,
                       end=planner.Pixel(0, 2),
                       oldcolor=0,
                       newcolor=0)
    ]
    assert tank.amount == planner.MAX_TANK - 3
def test_stroke_stack():
    start = planner.Pixel(0, 0)
    current = planner.Stroke(
        action=planner.
        INIT,  # I think this is a garbage value that will be overwritten
        end=start,
        oldcolor=0,
        newcolor=0)
    strokes = planner.StrokeStack(current)
    top_before = strokes.peek()
    strokes.push_instruction(action=planner.LIFT)
    top_after = strokes.peek()
    assert top_before.action == planner.INIT
    assert top_after.action == planner.LIFT