| @@ 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): |
|
| @@ 102-116 (lines=15) @@ | ||
| 99 | session.commit() |
|
| 100 | ||
| 101 | ||
| 102 | @pytest.mark.usefixtures("fixtures_filed_filtering") |
|
| 103 | def test_fields_filtering(session): |
|
| 104 | """Test if result's are filtered from global search field.""" |
|
| 105 | columns = [ |
|
| 106 | ColumnDT( |
|
| 107 | User.id, |
|
| 108 | ), |
|
| 109 | ColumnDT(User.name), |
|
| 110 | ] |
|
| 111 | ||
| 112 | query = session.query().select_from(User) |
|
| 113 | ||
| 114 | params = create_dt_params(columns, search="51") |
|
| 115 | rowTable = DataTables(params, query, columns) |
|
| 116 | res = rowTable.output_result() |
|
| 117 | ||
| 118 | assert len(res["data"]) == 1 |
|
| 119 | assert res["recordsTotal"] == "52" |
|