def testEven(self): for i in [1, 2, 7, 512, 1000, 1023]: lu = _FakeLU() result = instance_storage._DiskSizeInBytesToMebibytes(lu, i * 1024 * 1024) self.assertEqual(result, i) self.assertFalse(lu.warning_log)
def testLessThanOneMebibyte(self): for i in [1, 2, 7, 512, 1000, 1023]: lu = _FakeLU() result = instance_storage._DiskSizeInBytesToMebibytes(lu, i) self.assertEqual(result, 1) self.assertEqual(len(lu.warning_log), 1) self.assertEqual(len(lu.warning_log[0]), 2) (_, (warnsize, )) = lu.warning_log[0] self.assertEqual(warnsize, (1024 * 1024) - i)
def testLargeNumber(self): for i in [1, 2, 7, 512, 1000, 1023, 2724, 12420]: for j in [1, 2, 486, 326, 986, 1023]: lu = _FakeLU() size = (1024 * 1024 * i) + j result = instance_storage._DiskSizeInBytesToMebibytes(lu, size) self.assertEqual(result, i + 1, msg="Amount was not rounded up") self.assertEqual(len(lu.warning_log), 1) self.assertEqual(len(lu.warning_log[0]), 2) (_, (warnsize, )) = lu.warning_log[0] self.assertEqual(warnsize, (1024 * 1024) - j)