示例#1
0
def test_trolley_initial_call():
    view, reference_id = update_trolley()
    assert reference_id == "MToxOkU6MTIzNDU2"
    assert view == [
        'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'OR', 'O', 'O', 'O',
        'O', 'O', 'O', 'O', 'O', 'O', 'O', 'OR'
    ]
示例#2
0
def test_update_trolley_east_from_initial_location():
    view, reference_id = update_trolley('M', "MToxOkU6MTIzNDU2")
    assert reference_id == "MjoxOkU6MTIzNDU2"
    assert view == [
        'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'OR', 'O', 'O', 'O', 'O',
        'O', 'O', 'O', 'O', 'O', 'O', 'OR'
    ]
示例#3
0
def test_update_trolley_east_from_bottom_row():
    view, reference_id = update_trolley('M', "NDo4OkU6MTIzNDU2")
    assert reference_id == "NTo4OkU6MTIzNDU2"
    assert view == [
        'O', 'O', 'O', 'O', 'O', 'O', 'OL', 'O', 'O', 'O', 'O', 'O', 'O', 'O',
        'O', 'O', 'O', 'OL'
    ]
示例#4
0
def test_update_trolley_east_from_middle_row():
    view, reference_id = update_trolley('M', "NDo0OkU6MTIzNDU2")
    assert reference_id == "NTo0OkU6MTIzNDU2"
    assert view == [
        'O', 'O', 'O', 'O', 'O', 'O', 'OLR', 'O', 'O', 'O', 'O', 'O', 'O', 'O',
        'O', 'O', 'O', 'OLR'
    ]
示例#5
0
def test_move_trolley_when_facing_W_updates_correctly():
    reference_id = create_reference_id(13, 1, "W", "123456")

    view, reference_id = update_trolley('M', reference_id)

    x, y, orientation, trolley_id = decode_reference_id(reference_id)
    assert x == 12
    assert y == 1
    assert orientation == "W"
    assert view == ['O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'OL']
示例#6
0
def test_trolley_turn_left():
    reference_id = create_reference_id(1, 8, "E", "123456")

    view, reference_id = update_trolley('L', reference_id)

    x, y, orientation, trolley_id = decode_reference_id(reference_id)
    assert x == 1
    assert y == 8
    assert orientation == "N"
    assert view == ['O', 'O', 'O', 'OR', 'O', 'O', 'OR']
示例#7
0
def test_trolley_turn_right():
    reference_id = create_reference_id(1, 1, "E", "123456")

    view, reference_id = update_trolley('R', reference_id)

    x, y, orientation, trolley_id = decode_reference_id(reference_id)
    assert x == 1
    assert y == 1
    assert orientation == "S"
    assert view == ['O', 'O', 'OL', 'O', 'O', 'O', 'OL']
示例#8
0
def test_trolley_invalid_command():
    with pytest.raises(ValueError, match='Unknown command'):
        view, reference_id = update_trolley('X', "MToxOkU6MTIzNDU2")
示例#9
0
def test_update_trolley_east_is_blocked_so_move_ignored():
    view, reference_id = update_trolley('M', "MToyOkU6MTIzNDU2")
    assert reference_id == "MToyOkU6MTIzNDU2"
    assert view == []