@@ 89-103 (lines=15) @@ | ||
86 | session.commit() |
|
87 | ||
88 | ||
89 | @pytest.mark.usefixtures("fixtures_filed_filtering") |
|
90 | def test_fields_filtering(session): |
|
91 | """Test if result's are filtered from global search field.""" |
|
92 | columns = [ColumnDT(User.id, ), ColumnDT(User.name)] |
|
93 | ||
94 | query = session.query().select_from(User) |
|
95 | ||
96 | params = create_dt_params(columns, search='51') |
|
97 | rowTable = DataTables(params, query, columns) |
|
98 | res = rowTable.output_result() |
|
99 | ||
100 | assert len(res['data']) == 1 |
|
101 | assert res['recordsTotal'] == '52' |
|
102 | assert res['recordsFiltered'] == '1' |
|
103 | assert res['data'][0]['1'] == 'User 51' |
|
104 | ||
105 | ||
106 | @pytest.fixture(scope="function") |
@@ 9-22 (lines=14) @@ | ||
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 | assert len(res['data']) == 10 |
|
20 | assert len(res['data'][0]) == 1 |
|
21 | assert res['recordsTotal'] == '50' |
|
22 | assert res['recordsFiltered'] == '50' |
|
23 | ||
24 | ||
25 | def test_list_bad_length(session): |