def test_set(self) -> None: bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz") x = ComplexRef(name="foo", set_basetype_ref={1, 2, 3}, set_recursive_ref={bar, baz}) self.assertEqual(x.set_basetype_ref, {1, 2, 3}) self.assertEqual(x.set_recursive_ref, {bar, baz})
def test_list(self) -> None: bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz") x = ComplexRef(name="foo", list_basetype_ref=[1, 2, 3], list_recursive_ref=[bar, baz]) self.assertEqual(x.list_basetype_ref, [1, 2, 3]) self.assertEqual(x.list_recursive_ref, [bar, baz])
def test_map(self) -> None: bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz") x = ComplexRef( name="foo", map_basetype_ref={ 1: 1, 2: 2, 3: 3 }, map_recursive_ref={ 1: bar, 2: baz }, ) self.assertEqual(x.map_basetype_ref, {1: 1, 2: 2, 3: 3}) self.assertEqual(x.map_recursive_ref, {1: bar, 2: baz})
def test_create_default(self) -> None: x = ComplexRef() self.assertEqual(x.name, "") self.assertIsNone(x.list_basetype_ref) self.assertIsNone(x.list_recursive_ref) self.assertIsNone(x.set_basetype_ref) self.assertIsNone(x.set_recursive_ref) self.assertIsNone(x.map_basetype_ref) self.assertIsNone(x.map_recursive_ref)
def test_recursive(self) -> None: bar = ComplexRef(name="bar") baz = ComplexRef(recursive=bar) self.assertEqual(baz.recursive, bar)
def test_const_shared_ref(self) -> None: bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz") x = ComplexRef(name="foo", set_const_shared_ref={bar, baz}) self.assertEqual(x.set_const_shared_ref, {bar, baz})
def test_shared_ref(self) -> None: bar, baz = ComplexRef(name="bar"), ComplexRef(name="baz") x = ComplexRef(name="foo", list_shared_ref=[bar, baz]) self.assertEqual(x.list_shared_ref, [bar, baz])
def test_single(self) -> None: x = ComplexRef(name="foo", ref=ComplexRef(name="bar")) self.assertIsNotNone(x.ref) assert x.ref # for type checking self.assertEqual(x.ref.name, "bar")