Beispiel #1
0
def test__undictionize__object_method_works():
    data = {
        'name': 'Joe',
    }
    actual_obj = undictionize(data, Data)
    actual = actual_obj.hello()
    expected = 'hello Joe'
    assert expected == actual
Beispiel #2
0
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
Beispiel #3
0
def test__undictionize__sub_object():
    data = {'name': 'Joe', 'data': {'name': 'John'}}
    actual = undictionize(data, Data)
    expected = Data('Joe', 'John')
    assert expected == actual
Beispiel #4
0
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
Beispiel #5
0
def test__undictionize__object():
    data = {'name': 'Joe'}
    actual = undictionize(data, Data)
    expected = Data('Joe')
    assert expected == actual