コード例 #1
0
def test_move_moves_to_the_last_field_when_goes_out_of_the_board_from_start():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 10)

    assert board.further_fields[-1] == [turtle]
コード例 #2
0
def test_move_should_move_turtle_to_finish_from_start():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 9)

    assert board.further_fields[8] == [turtle]
コード例 #3
0
def test_turtle_stack_should_be_smaller_on_start_when_moved_from_start():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 0)

    assert len(board.start_field) == 0
コード例 #4
0
def test_turtle_should_move_to_second_field():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 2)

    assert board.further_fields[1] == [turtle]
コード例 #5
0
def test_turtle_should_move_to_third_field():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 3)

    assert board.further_fields[2] == [turtle]
コード例 #6
0
def test_turtle_shouldnt_be_on_first_when_moved_from_first_to_second():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 0)

    assert [turtle] not in board.start_field
コード例 #7
0
def test_is_last_should_return_true_for_turtle_after_move():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    actual = board.is_last(turtle)

    assert actual
コード例 #8
0
def test_turtle_should_be_on_start_after_moving_backward_from_second_field():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    board.move(turtle, -1)

    assert [turtle] in board.start_field
コード例 #9
0
def test_has_anyone_finished_should_return_true_when_turtle_is_on_finish():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 9)
    actual = board.has_anyone_finished()

    assert actual
コード例 #10
0
def test_turtle_is_not_in_the_second_field_after_moving_through_the_second():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    board.move(turtle, 1)

    assert board.further_fields[0] == []
コード例 #11
0
def test_turtle_shouldnt_be_on_the_same_field_after_moving_backward():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    board.move(turtle, -1)

    assert board.further_fields[0] != [turtle]
コード例 #12
0
def test_turtles_should_be_in_the_same_field_in_order_after_move_from_start():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)

    assert board.further_fields[0] == [turtle2, turtle1]
コード例 #13
0
def test_is_last_should_return_false_when_other_turtle_is_on_start():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle2, 1)
    actual = board.is_last(turtle2)

    assert not actual
コード例 #14
0
def test_is_move_possible_returns_true_when_backward_card_further_turtle():
    card = Card(0, 'RED', 'MINUS')
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    actual = board.is_move_with_card_possible(card)

    assert actual
コード例 #15
0
def test_is_move_possible_returns_true_when_rainbow_card_turtle_on_furter():
    turtle = Turtle('GREEN')
    board = Board([turtle])
    card = Card(0, 'RAINBOW', 'MINUS')

    board.move(turtle, 2)
    actual = board.is_move_with_card_possible(card)

    assert actual
コード例 #16
0
def test_has_anyone_finished_returns_false_when_players_are_in_the_middle():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 5)

    actual = board.has_anyone_finished()

    assert not actual
コード例 #17
0
def test_turtle_should_be_on_second_after_moving_backward_from_third():
    turtle = Turtle('RED')
    board = Board([turtle])

    board.move(turtle, 1)
    board.move(turtle, 1)
    board.move(turtle, -1)

    assert board.further_fields[0] == [turtle]
コード例 #18
0
def test_get_ranking_returns_turtles_sorted_by_position_when_no_stacks():
    turtle1 = Turtle('GREEN')
    turtle2 = Turtle('RED')
    board = Board([turtle1, turtle2])

    board.move(turtle2, 1)
    actual = board.get_ranking()

    assert actual == [turtle2, turtle1]
コード例 #19
0
def test_two_turtles_should_move_when_moving_bottom_turtle_from_further():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle1, 1)

    assert board.further_fields[1] == [turtle2, turtle1]
コード例 #20
0
def test_turtles_should_move_when_moving_bottom_turtle_from_further_to_start():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle1, -1)

    assert [turtle2, turtle1] in board.start_field
コード例 #21
0
def test_bottom_turtle_should_stay_when_moving_top_turtle_from_further():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle2, 1)

    assert board.further_fields[0] == [turtle1]
コード例 #22
0
def test_turtles_are_in_the_same_field_in_order_after_move_from_further():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 2)
    board.move(turtle2, 1)
    board.move(turtle2, 1)

    assert board.further_fields[1] == [turtle2, turtle1]
コード例 #23
0
def test_is_last_should_return_false_for_not_last_turtle():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 2)
    board.move(turtle2, 1)
    actual = board.is_last(turtle1)

    assert not actual
コード例 #24
0
def test_three_turtles_two_should_move_to_second_field_when_moving_middle():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    turtle3 = Turtle('GREEN')
    board = Board([turtle1, turtle2, turtle3])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle3, 1)
    board.move(turtle2, 1)

    assert board.further_fields[1] == [turtle3, turtle2]
コード例 #25
0
def test_three_turtles_one_should_stay_in_first_field_when_moving_middle():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    turtle3 = Turtle('GREEN')
    board = Board([turtle1, turtle2, turtle3])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle3, 1)
    board.move(turtle2, 1)

    assert board.further_fields[0] == [turtle1]
コード例 #26
0
def test_is_move_possible_returns_false_when_back_card_turtle_back_on_start():
    card = Card(0, 'RED', 'MINUS')
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle2, 1)
    board.move(turtle1, 1)
    board.move(turtle2, -1)

    actual = board.is_move_with_card_possible(card)

    assert not actual
コード例 #27
0
def test_get_ranking_returns_turtles_sorted_by_pos_when_there_are_stacks():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('GREEN')
    turtle3 = Turtle('YELLOW')
    board = Board([turtle1, turtle2, turtle3])

    board.move(turtle1, 3)
    board.move(turtle2, 2)
    board.move(turtle3, 2)

    actual = board.get_ranking()

    assert actual == [turtle1, turtle3, turtle2]
コード例 #28
0
def test_get_ranking_returns_turtles_sorted_by_position_when_stack_on_start():
    turtles = [Turtle('RED'), Turtle('YELLOW'), Turtle('GREEN'),
               Turtle('PURPLE'), Turtle('BLUE')]

    board = Board(turtles)

    # Turtles 0 and 1 stack on start:
    board.move(turtles[0], 1)
    board.move(turtles[1], 1)
    board.move(turtles[0], -1)

    # Turtles 2 and 3 stack on start:
    board.move(turtles[2], 1)
    board.move(turtles[3], 1)
    board.move(turtles[2], -1)

    board.move(turtles[4], 9)

    actual = board.get_ranking()

    assert actual == [turtles[4], turtles[1], turtles[3], turtles[0],
                      turtles[2]]
コード例 #29
0
def test_one_turtle_should_stay_at_start_when_moving_top_turtle_from_start():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle1, -1)
    board.move(turtle2, 1)

    assert [turtle1] in board.start_field
コード例 #30
0
def test_turtles_should_be_at_second_when_moving_bottom_turtle_from_start():
    turtle1 = Turtle('RED')
    turtle2 = Turtle('BLUE')
    board = Board([turtle1, turtle2])

    board.move(turtle1, 1)
    board.move(turtle2, 1)
    board.move(turtle1, -1)
    board.move(turtle1, 1)

    assert board.further_fields[0] == [turtle2, turtle1]