-
Notifications
You must be signed in to change notification settings - Fork 95
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 #277 from cwacek/fix/232
tests: Add a test to validate expected behavior on #232
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 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,28 @@ | ||
import json | ||
|
||
import python_jsonschema_objects as pjo | ||
|
||
|
||
def test_default_objects(): | ||
schema = { | ||
"title": "Example", | ||
"type": "object", | ||
"properties": { | ||
"url": { | ||
"type": "string", | ||
"default": "https://example.com/your-username/my-project", | ||
}, | ||
"type": {"type": "string", "default": "git"}, | ||
}, | ||
} | ||
|
||
ob = pjo.ObjectBuilder(schema) | ||
ns1 = ob.build_classes() | ||
ex = ns1.Example() | ||
assert ex.url == "https://example.com/your-username/my-project" | ||
assert ex.type == "git" | ||
|
||
data = {"url": "https://example.com/your-username/my-project2", "type": "hg"} | ||
ex2 = ns1.Example.from_json(json.dumps(data)) | ||
assert ex2.url == "https://example.com/your-username/my-project2" | ||
assert ex2.type == "hg" |