Skip to content

Commit

Permalink
Merge pull request #277 from cwacek/fix/232
Browse files Browse the repository at this point in the history
tests: Add a test to validate expected behavior on #232
  • Loading branch information
cwacek authored Dec 27, 2023
2 parents 7f781d9 + 86ecdf9 commit 4ea8b43
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_232.py
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"

0 comments on commit 4ea8b43

Please sign in to comment.