def test_defaults_no_defaults(self): with self.assertRaises(NoObjectDefaults): get_object_defaults({ 'type': 'object', 'properties': { 'address': { "type": 'object', 'properties': { 'street': { 'type': 'string', } } }, } })
def test_defaults_basic(self): self.assertEqual( get_object_defaults({ 'type': 'object', 'properties': { 'title': {"type": 'string'}, 'published': {"type": 'boolean', "default": True}, } }), { 'published': True, } )
def test_defaults_nested_object_default(self): self.assertEqual( get_object_defaults({ 'type': 'object', 'properties': { 'title': { "type": 'string' }, 'published': { "type": 'boolean', "default": True }, 'address': { 'type': 'object', 'properties': { 'country': { 'type': 'string', 'default': "Brazil", }, }, }, 'driver_license': { 'default': { 'category': "C" }, 'type': 'object', 'properties': { 'category': { "type": "string", "maxLength": 1, "minLength": 1, }, 'shipping_city': { "type": "string", "default": "Belo Horizonte", }, } } } }), { 'published': True, 'address': { 'country': "Brazil", }, 'driver_license': { "category": "C", "shipping_city": "Belo Horizonte", } })
def test_defaults_basic(self): self.assertEqual( get_object_defaults({ 'type': 'object', 'properties': { 'title': { "type": 'string' }, 'published': { "type": 'boolean', "default": True }, } }), { 'published': True, })
def test_defaults_nested_object_default(self): self.assertEqual( get_object_defaults({ 'type': 'object', 'properties': { 'title': {"type": 'string'}, 'published': {"type": 'boolean', "default": True}, 'address': { 'type': 'object', 'properties': { 'country': { 'type': 'string', 'default': "Brazil", }, }, }, 'driver_license': { 'default': {'category': "C"}, 'type': 'object', 'properties': { 'category': { "type": "string", "maxLength": 1, "minLength": 1, }, 'shipping_city': { "type": "string", "default": "Belo Horizonte", }, } } } }), { 'published': True, 'address': { 'country': "Brazil", }, 'driver_license': { "category": "C", "shipping_city": "Belo Horizonte", } } )