-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix example to work with Pydantic V2, add test for examples
- Loading branch information
Showing
5 changed files
with
43 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,7 @@ dmypy.json | |
|
||
# PyCharm / IntelliJ | ||
.idea/ | ||
|
||
# vim | ||
*.swp | ||
*.swo |
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
Empty file.
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,30 @@ | ||
from examples import departments | ||
|
||
|
||
def test_departments(): | ||
result = departments.main() | ||
assert not result.errors | ||
|
||
deps = result.data["listDepartments"] | ||
assert len(deps) == 1 | ||
|
||
employees = deps[0]["employees"] | ||
assert len(employees) == 3 | ||
|
||
def employee_by_name(employees, name): | ||
return [e for e in employees if e["name"] == name][0] | ||
|
||
jason = employee_by_name(employees, "Jason") | ||
carmen = employee_by_name(employees, "Carmen") | ||
derek = employee_by_name(employees, "Derek") | ||
|
||
# Jason is a manager | ||
assert jason["teamSize"] == 2 | ||
assert carmen.get("teamSize") is None | ||
|
||
# some sanity checks on optional fields, | ||
# knowing what the test data is | ||
assert jason.get("hiredOn") is None | ||
assert carmen.get("hiredOn") is not None | ||
assert carmen["salary"]["rating"] == "GS-9" | ||
assert derek["salary"] is None |