from solutions.dive import PART_TWO_MOVES, Submarine


def test_sub_moves_forward():
    """Given a command to move forward, the sub changes horizontal
    position.
    """
    sub = Submarine()
    assert sub.engage("forward 5").horizontal_position == 5


def test_sub_moves_down():
    """Given a command to move down, the sub changes depth."""
    sub = Submarine()
    assert sub.engage("down 5").depth == 5


def test_sub_moves_up():
    """Given a command to move up, the sub changes depth."""
    sub = Submarine()
    assert sub.engage("up 5").depth == -5


def test_sub_follows_path_to_final_position_value():
    """Sub can follow a path and calculate its final position's value."""
    sub = Submarine()
    commands = [
        "forward 5",
        "down 5",
        "forward 8",
        "up 3",
        "down 8",
        "forward 2",
    ]
    for command in commands:
        sub.engage(command)

    assert sub.horizontal_position == 15
    assert sub.depth == 10
    assert sub.final_value == 150


def test_sub_aims_down():
    """Given a command to move down, the sub changes aim."""
    sub = Submarine()
    assert sub.engage("down 5", moves=PART_TWO_MOVES).aim == 5


def test_sub_aims_up():
    """Given a command to move up, the sub changes aim."""
    sub = Submarine()
    assert sub.engage("up 5", moves=PART_TWO_MOVES).aim == -5


def test_sub_follows_path_to_final_position_value_part_two():
    """Sub can follow a path and calculate its final position's value."""
    sub = Submarine()
    commands = [
        "forward 5",
        "down 5",
        "forward 8",
        "up 3",
        "down 8",
        "forward 2",
    ]
    for command in commands:
        sub.engage(command, moves=PART_TWO_MOVES)

    assert sub.horizontal_position == 15
    assert sub.depth == 60
    assert sub.final_value == 900

from solutions.dive import PART_TWO_MOVES, Submarine


def test_sub_moves_forward():
    """Given a command to move forward, the sub changes horizontal
    position.
    """
    sub = Submarine()
    assert sub.engage("forward 5").horizontal_position == 5


def test_sub_moves_down():
    """Given a command to move down, the sub changes depth."""
    sub = Submarine()
    assert sub.engage("down 5").depth == 5


def test_sub_moves_up():
    """Given a command to move up, the sub changes depth."""
    sub = Submarine()
    assert sub.engage("up 5").depth == -5


def test_sub_follows_path_to_final_position_value():
    """Sub can follow a path and calculate its final position's value."""
    sub = Submarine()
    commands = [
        "forward 5",
        "down 5",
        "forward 8",
        "up 3",
        "down 8",
        "forward 2",
    ]
    for command in commands:
        sub.engage(command)

    assert sub.horizontal_position == 15
    assert sub.depth == 10
    assert sub.final_value == 150


def test_sub_aims_down():
    """Given a command to move down, the sub changes aim."""
    sub = Submarine()
    assert sub.engage("down 5", moves=PART_TWO_MOVES).aim == 5


def test_sub_aims_up():
    """Given a command to move up, the sub changes aim."""
    sub = Submarine()
    assert sub.engage("up 5", moves=PART_TWO_MOVES).aim == -5


def test_sub_follows_path_to_final_position_value_part_two():
    """Sub can follow a path and calculate its final position's value."""
    sub = Submarine()
    commands = [
        "forward 5",
        "down 5",
        "forward 8",
        "up 3",
        "down 8",
        "forward 2",
    ]
    for command in commands:
        sub.engage(command, moves=PART_TWO_MOVES)

    assert sub.horizontal_position == 15
    assert sub.depth == 60
    assert sub.final_value == 900

Given a command to move forward, the sub changes horizontal     position. Given a command to move down, the sub changes depth. Given a command to move up, the sub changes depth. Sub can follow a path and calculate its final position's value. Given a command to move down, the sub changes aim. Given a command to move up, the sub changes aim. Sub can follow a path and calculate its final position's value.