@@ 96-114 (lines=19) @@ | ||
93 | session.commit() |
|
94 | ||
95 | ||
96 | @pytest.mark.usefixtures("fixtures_filed_filtering") |
|
97 | def test_fields_filtering(session): |
|
98 | """Test if result's are filtered from global search field.""" |
|
99 | columns = [ColumnDT(User.id, ), ColumnDT(User.name)] |
|
100 | ||
101 | query = session.query().select_from(User) |
|
102 | ||
103 | params = create_dt_params(columns, search='51') |
|
104 | rowTable = DataTables(params, query, columns) |
|
105 | res = rowTable.output_result() |
|
106 | ||
107 | if not len(res['data']) == 1: |
|
108 | raise AssertionError() |
|
109 | if not res['recordsTotal'] == '52': |
|
110 | raise AssertionError() |
|
111 | if not res['recordsFiltered'] == '1': |
|
112 | raise AssertionError() |
|
113 | if not res['data'][0]['1'] == 'User 51': |
|
114 | raise AssertionError() |
|
115 | ||
116 | ||
117 | @pytest.fixture(scope="function") |
@@ 9-26 (lines=18) @@ | ||
6 | from .models import Address, User |
|
7 | ||
8 | ||
9 | def test_list(session): |
|
10 | """Test if it returns a list of users.""" |
|
11 | columns = [ColumnDT(User.id)] |
|
12 | ||
13 | query = session.query().select_from(User) |
|
14 | ||
15 | params = create_dt_params(columns) |
|
16 | rowTable = DataTables(params, query, columns) |
|
17 | res = rowTable.output_result() |
|
18 | ||
19 | if not len(res['data']) == 10: |
|
20 | raise AssertionError() |
|
21 | if not len(res['data'][0]) == 1: |
|
22 | raise AssertionError() |
|
23 | if not res['recordsTotal'] == '50': |
|
24 | raise AssertionError() |
|
25 | if not res['recordsFiltered'] == '50': |
|
26 | raise AssertionError() |
|
27 | ||
28 | ||
29 | def test_list_bad_length(session): |