def test_nested(self) -> None: nested = py3_types.Nested( simpleField=py3_types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={"one": 1, "two": 2}, color=py3_types.Color.NONE, ), simpleList=[ py3_types.Simple( intField=200, strField="face", intList=[4, 5, 6], strSet={"keep", "calm"}, strToIntMap={"three": 3, "four": 4}, color=py3_types.Color.RED, ), py3_types.Simple( intField=404, strField="b00k", intList=[7, 8, 9], strSet={"carry", "on"}, strToIntMap={"five": 5, "six": 6}, color=py3_types.Color.GREEN, ), ], colorToSimpleMap={ py3_types.Color.BLUE: py3_types.Simple( intField=500, strField="internal", intList=[10], strSet={"server", "error"}, strToIntMap={"seven": 7, "eight": 8, "nine": 9}, color=py3_types.Color.BLUE, ) }, )._to_py_deprecated() self.assertEqual(nested.simpleField.intField, 42) self.assertEqual(nested.simpleList[0].intList, [4, 5, 6]) self.assertEqual(nested.simpleList[1].strSet, {"carry", "on"}) self.assertEqual( nested.colorToSimpleMap[py_deprecated_types.Color.BLUE].color, py_deprecated_types.Color.BLUE, )
def test_complex_union(self) -> None: complex_union = py3_types.Union(simple_=py3_types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={ "one": 1, "two": 2 }, color=py3_types.Color.NONE, ))._to_python() self.assertEqual(complex_union.type, python_types.Union.Type.simple_) self.assertEqual(complex_union.simple_.intField, 42)
def test_complex_union(self) -> None: complex_union = py3_types.Union( simple_=py3_types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={"one": 1, "two": 2}, color=py3_types.Color.NONE, name_="renamed", ) )._to_py_deprecated() self.assertEqual(complex_union.get_simpleField().intField, 42) self.assertEqual(complex_union.get_simpleField().name, "renamed")
def test_complex_union(self) -> None: complex_union = to_py_struct( ttypes.Union, types.Union(simpleField=types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={ "one": 1, "two": 2 }, color=types.Color.NONE, )), ) self.assertEqual(complex_union.get_simpleField().intField, 42)
def test_simple(self) -> None: simple = py3_types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={"one": 1, "two": 2}, color=py3_types.Color.GREEN, name_="renamed", )._to_py_deprecated() self.assertEqual(simple.intField, 42) self.assertEqual(simple.strField, "simple") self.assertEqual(simple.intList, [1, 2, 3]) self.assertEqual(simple.strSet, {"hello", "world"}) self.assertEqual(simple.strToIntMap, {"one": 1, "two": 2}) self.assertEqual(simple.color, py_deprecated_types.Color.GREEN) self.assertEqual(simple.name, "renamed")
def test_simple(self) -> None: simple = to_py_struct( ttypes.Simple, types.Simple( intField=42, strField="simple", intList=[1, 2, 3], strSet={"hello", "world"}, strToIntMap={ "one": 1, "two": 2 }, color=types.Color.GREEN, ), ) self.assertEqual(simple.intField, 42) self.assertEqual(simple.strField, "simple") self.assertEqual(simple.intList, [1, 2, 3]) self.assertEqual(simple.strSet, {"hello", "world"}) self.assertEqual(simple.strToIntMap, {"one": 1, "two": 2}) self.assertEqual(simple.color, ttypes.Color.GREEN)