python magickmock constraint errors

Solutions on MaxInterview for python magickmock constraint errors by the best coders in the world

showing results for - "python magickmock constraint errors"
Jacobo
26 Jun 2016
1def test_check_unique_constraint(log):
2    mock_field = mock.MagicMock()
3    mock_field.descriptor = {'primaryKey': True}
4    mock_field.constraints['unique'] = True
5    cells1 = [
6        goodtables.cells.create_cell('name', 'value', mock_field, row_number=1, column_number=1),
7        goodtables.cells.create_cell('value', '50', mock_field, row_number=1, column_number=2),
8    ]
9    cells2 = [
10        goodtables.cells.create_cell('name', 'value', mock_field, row_number=2, column_number=1),
11        goodtables.cells.create_cell('value', '100', mock_field, row_number=2, column_number=2),
12    ]
13    duplicate_row = UniqueConstraint()
14    errors = duplicate_row.check_row(cells1)
15    errors += duplicate_row.check_row(cells2)
16
17    assert log(errors) == [
18        (2, 1, 'unique-constraint'),
19    ]