Exemple #1
0
def test_board_group_board_by_serial():
    """Test that the boards property works with serial indices."""
    board_group = BoardGroup(MockBoard, OneBoardMockBackend())
    BoardGroup(MockBoard, OneBoardMockBackend())

    assert type(board_group[list(
        board_group.boards.values())[0].serial]) == MockBoard
Exemple #2
0
def test_board_group_str():
    """Test that the board group can be represented as a string."""
    assert str(BoardGroup(MockBoard,
                          NoBoardMockBackend())) == "Group of Boards - []"
    assert str(BoardGroup(MockBoard, OneBoardMockBackend())) == \
        "Group of Boards - [Testing Board - TESTSERIAL1]"
    assert str(BoardGroup(MockBoard, TwoBoardsMockBackend())) == \
        "Group of Boards - [Testing Board - TESTSERIAL1, Testing Board - TESTSERIAL2]"
Exemple #3
0
def test_board_group_boards_zero():
    """Test that the boards property works with no boards."""
    board_group = BoardGroup(MockBoard, NoBoardMockBackend())

    assert len(board_group.boards) == 0

    with pytest.raises(KeyError):
        board_group.boards["SERIAL0"]
Exemple #4
0
def test_board_group_simultaneous_iteration():
    """Test that iterators returned by iter(BoardGroup) are independent."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())
    iter1 = iter(board_group)
    iter2 = iter(board_group)
    assert next(iter1) is board_group["TESTSERIAL1"]
    assert next(iter2) is board_group["TESTSERIAL1"]
    assert next(iter1) is board_group["TESTSERIAL2"]
    assert next(iter2) is board_group["TESTSERIAL2"]
Exemple #5
0
def test_board_group_iteration():
    """Test that we can iterate over a BoardGroup."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())

    count = 0

    for b in board_group:
        assert type(b) == MockBoard
        count += 1

    assert count == 2
Exemple #6
0
def test_board_group_board_by_unknown():
    """Test that the boards property throws an exception with unknown indices."""
    board_group = BoardGroup(MockBoard, OneBoardMockBackend())

    with pytest.raises(TypeError):
        board_group[0]

    with pytest.raises(KeyError):
        board_group[""]

    with pytest.raises(TypeError):
        board_group[{}]

    with pytest.raises(KeyError):
        board_group["ARGHHHJ"]
Exemple #7
0
def test_board_group_iteration_sorted_by_serial():
    """Test that the boards yielded by iterating over a BoardGroup are sorted."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())
    serials = [board.serial for board in board_group]
    assert len(serials) == 2
    assert serials[0] < serials[1]
Exemple #8
0
def test_board_group_length_zero():
    """Test that the length operator works with no boards."""
    board_group = BoardGroup(MockBoard, NoBoardMockBackend())

    assert len(board_group) == 0
Exemple #9
0
def test_board_group_length_multiple():
    """Test that the length operator works on multiple boards."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())

    assert len(board_group) == 2
Exemple #10
0
def test_board_group_length():
    """Test that the length operator works on a board group."""
    board_group = BoardGroup(MockBoard, OneBoardMockBackend())

    assert len(board_group) == 1
Exemple #11
0
def test_board_group_boards_multiple():
    """Test that the boards property works on multiple boards."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())

    assert len(board_group.boards) == 2
    assert type(list(board_group.boards.values())[0]) == MockBoard
Exemple #12
0
def test_board_group_boards():
    """Test that the boards property works on a board group."""
    board_group = BoardGroup(MockBoard, OneBoardMockBackend())

    assert len(board_group.boards) == 1
    assert type(list(board_group.boards.values())[0]) == MockBoard
Exemple #13
0
def test_board_group_singular_but_multiple_boards():
    """Test that the singular function gets upset if there are multiple boards."""
    board_group = BoardGroup(MockBoard, TwoBoardsMockBackend())

    with pytest.raises(Exception):
        board_group.singular()
Exemple #14
0
def test_board_group_singular():
    """Test that the singular function works on a board group."""
    board_group = BoardGroup(MockBoard, OneBoardMockBackend())

    assert type(board_group.singular()) == MockBoard
Exemple #15
0
def test_board_group_update():
    """Test that we can create a board group of testing boards."""
    board_group = BoardGroup(MockBoard, NoBoardMockBackend())
    board_group.update_boards()
Exemple #16
0
def test_create_boardgroup():
    """Test that we can create a board group of testing boards."""
    board_group = BoardGroup(MockBoard, NoBoardMockBackend())
    assert type(board_group) == BoardGroup