-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to check that invalid module specifications fail
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from wysdom import UserObject, UserProperty | ||
|
||
|
||
class Person(UserObject): | ||
first_name: str = UserProperty(str) | ||
last_name: str = UserProperty(str, default="", default_function=lambda x: x.first_name) |
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,6 @@ | ||
from wysdom import UserObject, UserProperty | ||
|
||
|
||
class Person(UserObject): | ||
first_name: str = UserProperty(str) | ||
last_name: str = UserProperty(str, default="", optional=False) |
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,17 @@ | ||
Feature: Test that invalid module specifications fail | ||
|
||
Scenario: Fail if both default and default_function are set | ||
|
||
When we try to load the Python module invalid_both_defaults.py | ||
Then a ValueError is raised with text: | ||
""" | ||
Cannot use both default and default_function. | ||
""" | ||
|
||
Scenario: Fail if both default is set and optional is set to False | ||
|
||
When we try to load the Python module invalid_required_and_default.py | ||
Then a ValueError is raised with text: | ||
""" | ||
Cannot set optional to False if default or default_function are specified. | ||
""" |
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