-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from codemation/model-filter-counting
Feature - DataBaseModel Count and filter count
- Loading branch information
Showing
5 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
from tests.models import EmployeeInfo | ||
|
||
@pytest.mark.asyncio | ||
async def test_model_counting(loaded_database_and_model): | ||
db, Employees = loaded_database_and_model | ||
|
||
all_employees = await Employees.all() | ||
employee_count = await Employees.count() | ||
|
||
print(f"Number of Employees is ", employee_count) | ||
|
||
assert employee_count == len(all_employees) | ||
|
||
employed = await Employees.filter( | ||
is_employed=True | ||
) | ||
|
||
employed_count = await Employees.filter( | ||
is_employed=True, | ||
count_rows=True, | ||
) | ||
|
||
assert len(employed) == employed_count | ||
|
||
un_employed = await Employees.filter( | ||
is_employed=False, | ||
count_rows=True | ||
) | ||
assert un_employed == 0 | ||
|