File tree 2 files changed +9
-5
lines changed
python_jsonschema_objects
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ def __repr__(self):
52
52
def from_json (cls , jsonmsg ):
53
53
import json
54
54
msg = json .loads (jsonmsg )
55
- return cls (** msg )
55
+ obj = cls (** msg )
56
+ obj .validate ()
57
+ return obj
56
58
57
59
def __init__ (this , ** props ):
58
60
this ._extended_properties = dict ()
@@ -68,15 +70,15 @@ def __init__(this, **props):
68
70
69
71
try :
70
72
logging .debug ("Setting value for '{0}' to {1}"
71
- .format (prop , props [prop ]))
73
+ .format (prop , props [prop ]))
72
74
setattr (this , prop , props [prop ])
73
75
except validators .ValidationError as e :
74
76
import sys
75
77
raise type (e ), type (e )(str (e ) + " \n while setting '{0}' in {1}" .format (
76
78
prop , this .__class__ .__name__ )), sys .exc_info ()[2 ]
77
79
78
- if len (props ) > 0 :
79
- this .validate ()
80
+ # if len(props) > 0:
81
+ # this.validate()
80
82
81
83
def __setattr__ (self , name , val ):
82
84
if name .startswith ("_" ):
Original file line number Diff line number Diff line change @@ -98,7 +98,9 @@ def set_status(status):
98
98
str (person .lastName ).should .equal ("Bond" )
99
99
100
100
it 'should not allow required attributes to be missing' :
101
- self .Person .when .called_with (firstName = "James" ).should .throw (
101
+ person = self .Person (firstName = "James" )
102
+
103
+ person .validate .when .called_with ().should .throw (
102
104
pjs .ValidationError
103
105
)
104
106
You can’t perform that action at this time.
0 commit comments