def test_determine_unit_symbol_quantity(self): for category in [ Information.BINARY_BITS, Information.BINARY_BYTES, Information.DECIMAL_BITS, Information.DECIMAL_BYTES ]: expanded = Information._expand_units(category) for unit, bits in six.iteritems(expanded): # ensure this unit is used when we want to represent the exact # amount of data that it is equivalent to self.assertEqual( Information._determine_unit_symbol_quantity( bits, category), unit) # we should also use the same unit for this number of bits + 1 # (assuming units are not close together) self.assertEqual( Information._determine_unit_symbol_quantity( bits + 1, category), unit)
def test_expand_units(self): units = ['TiB', 'B', 'YiB'] self.assertEqual( Information._expand_units(units), OrderedDict([(unit, Information._SYMBOLS[unit]) for unit in units]))