Beispiel #1
0
def test_validate_table_input_bad_colors(headers, rows):
    with pytest.raises(ValueError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
            colors='asdf',
        )

    assert 'Colors are set but are not a proper list.' in str(error.value)
Beispiel #2
0
def test_validate_table_input_colors_bad_length(headers, rows):
    with pytest.raises(IndexError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
            colors=[1, 2],
        )

    assert 'The number of colors does not match the number of columns.' in str(
        error.value)
Beispiel #3
0
def test_validate_table_input_bad_rows(headers):
    rows = '123'
    with pytest.raises(ValueError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
        )

    assert 'Rows are either not set or are not a proper list.' in str(
        error.value)
Beispiel #4
0
def test_validate_table_input_no_headers(rows):
    headers = None
    with pytest.raises(ValueError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
        )

    assert 'Headers are either not set or are not a proper list.' in str(
        error.value)
Beispiel #5
0
def test_validate_table_input_bad_row_in_rows():
    headers = ['column1']
    rows = [
        '123',
    ]
    with pytest.raises(IndexError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
        )

    assert 'Row 1 is not a proper list.' in str(error.value)
Beispiel #6
0
def test_validate_table_input_mismatching_column_length():
    headers = ['column1', 'column2']
    rows = [
        ['123'],
    ]
    with pytest.raises(IndexError) as error:
        _validate_table_input(
            headers=headers,
            rows=rows,
        )

    assert 'Row 1 has 1 column(s) which does not match the table columns of 2.' in str(
        error.value)