def testChild(self): b = BlockInfo(None, "/Foo", False, "") b2 = BlockInfo(None, "/Foo/bar", False, "") b21 = BlockInfo(None, "/Foo/bar/child", False, "") b3 = BlockInfo(None, "/Foo/bar1", False, "") b2.addChildBlock(b21) b.addChildBlock(b2) b.addChildBlock(b3) self.assertEqual(b2.parent, b) self.assertEqual(b3.parent, b) self.assertIn(b2.name, b.children) self.assertIn(b2.name, b.children_list) self.assertEqual(b.children_list.index(b2.name), 0) self.assertEqual(b.children_list.index(b3.name), 1) b.moveChildBlock(b3.name, 0) self.assertEqual(b.children_list.index(b2.name), 1) self.assertEqual(b.children_list.index(b3.name), 0) b.renameChildBlock("bar", "foo") self.assertEqual(b2.path, "/Foo/foo") self.assertEqual(b2.children["child"].path, "/Foo/foo/child") b.renameChildBlock("foo", "bar1") self.assertEqual(b2.path, "/Foo/foo") b.renameChildBlock("foo1", "bar1") self.assertEqual(b2.path, "/Foo/foo") b2.removeChildBlock("foo") b2.removeChildBlock("child") self.assertEqual(len(b2.children_list), 0) self.assertEqual(len(b2.children.keys()), 0)
def testCopy(self): b = BlockInfo(None, "/Foo", False, "") b.addUserParam("p0", "val0") b.addUserParam("p1", "val1") b2 = BlockInfo(None, "/Foo/bar", False, "") b2.addUserParam("p2", "val2") b2.addUserParam("p3", "val3") b3 = BlockInfo(None, "/Foo/bar1", False, "") b3.addUserParam("p4", "val4") b3.addUserParam("p5", "val5") b.addChildBlock(b2) b.addChildBlock(b3) b.setStarInfo(BlockInfo(None, "Foo/star", False, "")) b.addBlockType(BlockInfo(None, "Foo/t", False, "")) b_copy = b.copy(None) self.assertNotEqual(b_copy, b) self.assertEqual(b_copy.name, b.name) self.assertEqual(b_copy.types.keys(), b.types.keys()) self.assertNotEqual(b_copy.types, b.types) self.assertEqual(b_copy.children.keys(), b.children.keys()) self.assertEqual(b_copy.children_list, b.children_list) self.assertEqual(b_copy.parameters_list, b.parameters_list) self.assertEqual(b_copy.parameters.keys(), b.parameters.keys()) o = b.dump() o1 = b_copy.dump() self.assertEqual(o, o1)
def testChild(self): b = BlockInfo(None, "/Foo", False, "") b2 = BlockInfo(None, "/Foo/bar", False, "") b21 = BlockInfo(None, "/Foo/bar/child", False, "") b3 = BlockInfo(None, "/Foo/bar1", False, "") b2.addChildBlock(b21) b.addChildBlock(b2) b.addChildBlock(b3) self.assertEqual(b2.parent, b) self.assertEqual(b3.parent, b) self.assertIn(b2.name, b.children) self.assertIn(b2.name, b.children_list) self.assertEqual(b.children_list.index(b2.name), 0) self.assertEqual(b.children_list.index(b3.name), 1) b.moveChildBlock(b3.name, 0) self.assertEqual(b.children_list.index(b2.name), 1) self.assertEqual(b.children_list.index(b3.name), 0) b.renameChildBlock("bar", "foo") self.assertEqual(b2.path, "/Foo/foo") self.assertEqual(b2.children["child"].path, "/Foo/foo/child") b.renameChildBlock("foo", "bar1") self.assertEqual(b2.path, "/Foo/foo") b.renameChildBlock("foo1", "bar1") self.assertEqual(b2.path, "/Foo/foo") b2.removeChildBlock("foo") b2.removeChildBlock("child") self.assertEqual(len(b2.children_list), 0) self.assertEqual(len(b2.children.keys()), 0)
def testCopy(self): b = BlockInfo(None, "/Foo", False, "") b.addUserParam("p0", "val0") b.addUserParam("p1", "val1") b2 = BlockInfo(None, "/Foo/bar", False, "") b2.addUserParam("p2", "val2") b2.addUserParam("p3", "val3") b3 = BlockInfo(None, "/Foo/bar1", False, "") b3.addUserParam("p4", "val4") b3.addUserParam("p5", "val5") b.addChildBlock(b2) b.addChildBlock(b3) b.setStarInfo(BlockInfo(None, "Foo/star", False, "")) b.addBlockType(BlockInfo(None, "Foo/t", False, "")) b_copy = b.copy(None) self.assertNotEqual(b_copy, b) self.assertEqual(b_copy.name, b.name) self.assertEqual(b_copy.types.keys(), b.types.keys()) self.assertNotEqual(b_copy.types, b.types) self.assertEqual(b_copy.children.keys(), b.children.keys()) self.assertEqual(b_copy.children_list, b.children_list) self.assertEqual(b_copy.parameters_list, b.parameters_list) self.assertEqual(b_copy.parameters.keys(), b.parameters.keys()) o = b.dump() o1 = b_copy.dump() self.assertEqual(o, o1)
def testBasic(self): b = BlockInfo(None, "/Foo", False, "") b1 = BlockInfo(None, "/Foo/bar", False, "") b.addChildBlock(b1) self.assertEqual(b1.parent, b) self.assertIn(b1.name, b.children_list) self.assertIn(b1.name, b.children) b.types[b1.name] = b1 b.star_node = b1 out = b.dump() self.assertIn("/Foo/bar", out)
def testBasic(self): b = BlockInfo(None, "/Foo", False, "") b1 = BlockInfo(None, "/Foo/bar", False, "") b.addChildBlock(b1) self.assertEqual(b1.parent, b) self.assertIn(b1.name, b.children_list) self.assertIn(b1.name, b.children) b.types[b1.name] = b1 b.star_node = b1 out = b.dump() self.assertIn("/Foo/bar", out)