Example #1
0
def test_move():
    with open(f"{TEST_FILE_PATH}/test_input.txt") as f:
        test_map = f.read().splitlines()
    test_tt = TobogganTrajectory(input_map=test_map, move_x=3, move_y=1)
    test_tt.move()
    assert test_tt.current_x == 3
    assert test_tt.current_y == 1
Example #2
0
def test_move_y_boundary():
    with open(f"{TEST_FILE_PATH}/test_input.txt") as f:
        test_map = f.read().splitlines()
    test_tt = TobogganTrajectory(input_map=test_map, move_x=3, move_y=1)
    test_tt.current_y = len(test_tt.base_map)
    with pytest.raises(OutOfBoundsError):
        test_tt.move()
Example #3
0
def test_out_of_boundary_extend_called():
    mocked_extend = mock.Mock()
    with open(f"{TEST_FILE_PATH}/test_input.txt") as f:
        test_map = f.read().splitlines()
    with mock.patch.object(TobogganTrajectory, "extend_map", mocked_extend):
        test_tt = TobogganTrajectory(input_map=test_map, move_x=3, move_y=1)
        test_tt.current_x = test_tt.boundary
        test_tt.move()
    assert mocked_extend.call_count == 1