def test__undictionize__object_method_works(): data = { 'name': 'Joe', } actual_obj = undictionize(data, Data) actual = actual_obj.hello() expected = 'hello Joe' assert expected == actual
def test__undictionize__complex_object(): data = { 'required': 'required', 'optional': 'optional', 'args': [ 'arg1', 'arg2', ], 'kwargs': { 'hello': 'world', 'hola': 'mundo', } } actual = undictionize(data, ComplexObject) expected = ComplexObject( 'required', 'arg1', 'arg2', optional='optional', hello='world', hola='mundo', ) assert expected == actual
def test__undictionize__sub_object(): data = {'name': 'Joe', 'data': {'name': 'John'}} actual = undictionize(data, Data) expected = Data('Joe', 'John') assert expected == actual
def test__undictionize__array_of_sub_ojects(): data = {'name': 'Joe', 'datas': [{'name': 'John'}, {'name': 'Jesse'}]} actual = undictionize(data, Data) expected = Data('Joe', datas=[Data('John'), Data('Jesse')]) assert expected == actual
def test__undictionize__object(): data = {'name': 'Joe'} actual = undictionize(data, Data) expected = Data('Joe') assert expected == actual