示例#1
0
def parseDataSize(dataSize):
    parsedDataSize = parse(dataSize)

    if parsedDataSize == None:
        sys.exit("Can't parse data size '%s'" % (dataSize))

    (quantity, unit) = parsedDataSize

    numBytes = convert(quantity, unit, "B")
    return int(numBytes)
    def test_parse(self):
        test_cases = {
            "100GiB" : (100.0, "GiB"),
            "250.6 Gb" : (250.6, "Gb"),
            "100 MBps" : (100, "MBps"),
            "250foos" : None,
            "two hundred and fifty Gb" : None}

        for input_string, expected in test_cases.items():
            self.assertEquals(expected, uc.parse(input_string))
示例#3
0
    def test_parse(self):
        test_cases = {
            "100GiB": (100.0, "GiB"),
            "250.6 Gb": (250.6, "Gb"),
            "100 MBps": (100, "MBps"),
            "250foos": None,
            "two hundred and fifty Gb": None
        }

        for input_string, expected in test_cases.items():
            self.assertEquals(expected, uc.parse(input_string))