def test_release_delay(self): q.account_for_delayed_release(101, self.ts) q.quantize_period(self.qlen, self.ts) self.assertEqual(self.ts[0].cost, 100) self.assertEqual(self.ts[1].cost, 39) self.assertEqual(self.ts[2].cost, 51) self.assertTrue(is_integral(self.ts[0].period)) self.assertTrue(is_integral(self.ts[1].period)) self.assertTrue(is_integral(self.ts[2].period)) self.assertEqual(self.ts[0].period, 850) self.assertEqual(self.ts[1].period, 900) self.assertEqual(self.ts[2].period, 450)
def test_staggering(self): q.account_for_staggering(self.qlen, 4, self.ts) self.assertAlmostEqual(self.ts[0].period, 1000 - 37.5) self.assertAlmostEqual(self.ts[1].period, 1050 - 37.5) self.assertAlmostEqual(self.ts[2].period, 599 - 37.5) self.assertEqual(self.ts[0].cost, 100) self.assertEqual(self.ts[1].cost, 39) self.assertEqual(self.ts[2].cost, 51) q.quantize_period(self.qlen, self.ts) self.assertEqual(self.ts[0].period, 950) self.assertEqual(self.ts[1].period, 1000) self.assertEqual(self.ts[2].period, 550)
def test_period(self): q.quantize_period(self.qlen, self.ts) self.assertEqual(self.ts[0].cost, 100) self.assertEqual(self.ts[1].cost, 39) self.assertEqual(self.ts[2].cost, 51) self.assertTrue(is_integral(self.ts[0].period)) self.assertTrue(is_integral(self.ts[1].period)) self.assertTrue(is_integral(self.ts[2].period)) self.assertEqual(self.ts[0].period, 1000) self.assertEqual(self.ts[1].period, 1050) self.assertEqual(self.ts[2].period, 550) self.assertEqual(self.ts[0].deadline, 1000) self.assertEqual(self.ts[1].deadline, 1050) self.assertEqual(self.ts[2].deadline, 599)