def test_complex(self): '''Test encoding and decoding of a complex type value''' type_ = protocol.Product( protocol.UINT32, protocol.List(protocol.STRING), protocol.Option(protocol.Product( protocol.UINT32, protocol.STRING))) def handler(value): return (value[0], tuple(reversed(value[1])), value[2]) self._run_test(type_, ((0, ('abc', 'def',), (1, 'abc'))), handler) self._run_test(type_, ((0, ('abc',), None)), handler)
def test_complex(self): '''Test checking of a complex, nested type''' type_ = protocol.Product( protocol.UINT32, protocol.List(protocol.STRING), protocol.Option(protocol.Product(protocol.UINT32, protocol.STRING))) self._run_test(type_, ((0, ( 'abc', 'def', ), (1, 'abc')), True), ((0, ('abc', ), None), True), ((-1, (), None), False))
def test_product(self): '''Test encoding and decoding of product values''' type_ = protocol.Product(protocol.BOOL, protocol.STRING) self._run_test(type_, (True, 'abc')) self._run_test(type_, (False, ''))
def test_product(self): '''Test product checks''' type_ = protocol.Product(protocol.UINT32, protocol.STRING) self._run_test(type_, ((0, 'abc'), True), ((1, ''), True), ((), False), (None, False), ((-1, 'abc'), False), ((0, None), False), ('abc', False), (u'abc', False), )