def test_find_left_right_patch_multiple_pixels(sample_matrix): patch = [] color = 1 planner.find_left_right_patch( image=sample_matrix[2:], patch=patch, color=color, ) assert len(patch) == 2 assert patch == [planner.Pixel(0, 1), planner.Pixel(0, 2)]
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 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 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_find_left_right_patch_single_pixel(sample_matrix): patch = [] color = 1 success = planner.find_left_right_patch( image=sample_matrix, patch=patch, color=color, ) assert success assert len(patch) == 1 # this still seems like x should be 0 and y should be 1, but we are wrong and in reverse! assert patch[0] == planner.Pixel(1, 0)
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
def test_pixel(): pixel = planner.Pixel(3, 4) assert pixel.y == 3 assert pixel.x == 4