| Total Complexity | 11 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | |||
| 3 | from datatables import ColumnDT |
||
| 4 | |||
| 5 | from .models import User |
||
| 6 | |||
| 7 | |||
| 8 | def test_init_with_default_params(): |
||
| 9 | """Return column with given default params.""" |
||
| 10 | col = ColumnDT(User.id) |
||
| 11 | |||
| 12 | if not (col.nulls_order is None or col.search_method == 'string_contains'): |
||
| 13 | raise AssertionError() |
||
| 14 | |||
| 15 | |||
| 16 | def test_with_filter_ok(): |
||
| 17 | """Return column with a specific filter.""" |
||
| 18 | col = ColumnDT(User.name, search_method='like') |
||
| 19 | |||
| 20 | if col.search_method != 'like': |
||
| 21 | raise AssertionError() |
||
| 22 | |||
| 23 | |||
| 24 | def test_with_valid_nulls_order(): |
||
| 25 | """Return column with a specific filter.""" |
||
| 26 | col = ColumnDT(User.name, nulls_order='nullslast') |
||
| 27 | |||
| 28 | if col.nulls_order != 'nullslast': |
||
| 29 | raise AssertionError() |
||
| 30 | |||
| 31 | |||
| 32 | def test_with_invalid_nulls_order(): |
||
| 33 | """Return column with a specific filter.""" |
||
| 34 | with pytest.raises(ValueError): |
||
| 35 | ColumnDT(User.name, nulls_order='invalid') |
||
| 36 | |||
| 37 | |||
| 38 | def test_with_invalid_search_method(): |
||
| 39 | """Return column with a specific filter.""" |
||
| 40 | with pytest.raises(ValueError): |
||
| 41 | ColumnDT(User.name, search_method='invalid') |
||
| 42 |