def testParseLvInfoLine(self):
    """Tests for LogicalVolume._ParseLvInfoLine."""
    broken_lines = [
      "  toomuch#-wi-ao#253#3#4096.00#2#/dev/abc(20)",
      "  -wi-ao#253#3#4096.00#/dev/abc(20)",
      "  -wi-a#253#3#4096.00#2#/dev/abc(20)",
      "  -wi-ao#25.3#3#4096.00#2#/dev/abc(20)",
      "  -wi-ao#twenty#3#4096.00#2#/dev/abc(20)",
      "  -wi-ao#253#3.1#4096.00#2#/dev/abc(20)",
      "  -wi-ao#253#three#4096.00#2#/dev/abc(20)",
      "  -wi-ao#253#3#four#2#/dev/abc(20)",
      "  -wi-ao#253#3#4096..00#2#/dev/abc(20)",
      "  -wi-ao#253#3#4096.00#2.0#/dev/abc(20)",
      "  -wi-ao#253#3#4096.00#two#/dev/abc(20)",
      ]
    for broken in broken_lines:
      self.assertRaises(errors.BlockDeviceError,
                        bdev.LogicalVolume._ParseLvInfoLine, broken, "#")

    # Examples of good lines from "lvs":
    #  -wi-ao|253|3|4096.00|2|/dev/sdb(144),/dev/sdc(0)
    #  -wi-a-|253|4|4096.00|1|/dev/sdb(208)
    true_out = [
      ("-wi-ao", 253, 3, 4096.00, 2, ["/dev/abc"]),
      ("-wi-a-", 253, 7, 4096.00, 4, ["/dev/abc"]),
      ("-ri-a-", 253, 4, 4.00, 5, ["/dev/abc", "/dev/def"]),
      ("-wc-ao", 15, 18, 4096.00, 32, ["/dev/abc", "/dev/def", "/dev/ghi0"]),
      # Physical devices might be missing with thin volumes
      ("twc-ao", 15, 18, 4096.00, 32, []),
      ]
    for exp in true_out:
      for sep in "#;|":
        pvs = ",".join("%s(%s)" % (d, i * 12) for (i, d) in enumerate(exp[-1]))
        lvs_line = (sep.join(("  %s", "%d", "%d", "%.2f", "%d", "%s")) %
                    (exp[0:-1] + (pvs,)))
        parsed = bdev.LogicalVolume._ParseLvInfoLine(lvs_line, sep)
        self.assertEqual(parsed, exp)
dataset/ETHPy150Open ganeti/ganeti/test/py/ganeti.storage.bdev_unittest.py/TestLogicalVolume.testParseLvInfoLine/original