Example #1
0
def tuple_dict():
    PT = procrustes.Tuple(I, S, I)
    PD = procrustes.Dict({'a': I, 'b': S, 'c': PT})
    pd = PD({'b': 'kuku', 'c': (None, 'Lorem', 91)})
    Assert(pd.data) == {'a': None, 'c': (None, 'Lorem', None), 'b': 'kuku'}
    pd = PD({'b': 'kuku', 'c': (None, 'Lorem', 90)})
    Assert(pd.data) == {'a': None, 'c': (None, 'Lorem', 90), 'b': 'kuku'}
Example #2
0
def empty_flatten():
    I = procrustes.Integer(max=90, required=False)
    S = procrustes.String()
    PL = procrustes.List(I)
    PD = procrustes.Dict({'a': I, 'b': S})
    PT = procrustes.Tuple(I, S, I, PL, PD)

    Assert(dict(PT().flatten())) == {
        '4__b': None,
        '4__a': None,
        '1': None,
        '0': None,
        '2': None,
        '3__0': None
    }
Example #3
0
def flat_deepen():
    PT = procrustes.Tuple(I, S, I)
    PD = procrustes.Dict({'a': I, 'b': S, 'c': PT})
    pd = PD({'b': 'kuku', 'c': (None, 'Lorem', 78)})
    flat = dict(pd.flatten())
    Assert(flat) == {
        'a': None,
        'c__2': 78,
        'c__1': 'Lorem',
        'c__0': None,
        'b': 'kuku'
    }
    flat = {'a': None, 'c__2': 78, 'c__1': 'Lorem', 'b': 'kuku'}
    deep = PD.deepen(flat)
    Assert(deep) == {'a': None, 'c': (None, 'Lorem', 78), 'b': 'kuku'}
    pd = PD(deep)
    Assert(pd.data) == {'a': None, 'c': (None, 'Lorem', 78), 'b': 'kuku'}
Example #4
0
def simple_tuple():
    """Simple tuple ops"""
    PT = procrustes.Tuple(I, S, I)
    pt = PT([10, 'sdfsdf', 30])
    Assert(pt.data) == (10, 'sdfsdf', 30)