Answers for "Python magickmock constraint errors"

1

Python magickmock constraint errors

def test_check_unique_constraint(log):
    mock_field = mock.MagicMock()
    mock_field.descriptor = {'primaryKey': True}
    mock_field.constraints['unique'] = True
    cells1 = [
        goodtables.cells.create_cell('name', 'value', mock_field, row_number=1, column_number=1),
        goodtables.cells.create_cell('value', '50', mock_field, row_number=1, column_number=2),
    ]
    cells2 = [
        goodtables.cells.create_cell('name', 'value', mock_field, row_number=2, column_number=1),
        goodtables.cells.create_cell('value', '100', mock_field, row_number=2, column_number=2),
    ]
    duplicate_row = UniqueConstraint()
    errors = duplicate_row.check_row(cells1)
    errors += duplicate_row.check_row(cells2)

    assert log(errors) == [
        (2, 1, 'unique-constraint'),
    ]
Posted by: Guest on June-28-2021

Python Answers by Framework

Browse Popular Code Answers by Language