def test_dq_period_unevenstart(self): p = OutputPort('SW1') p.queues = {None} p._M_Windows = np.array([[0, 0, 100]]) p._free_period = 1337 p.dq_modify_period(True) self.assertEqual(p._free_period, 668)
def test_dq_period_zero(self): p = OutputPort('SW1') p._free_period = 0 ret = p.dq_modify_period(True) self.assertEqual(p._free_period, 0) self.assertEqual(ret, False) ret = p.dq_modify_period(False) self.assertEqual(p._free_period, 0) self.assertEqual(ret, False)
def test_dq_period_normal(self): p = OutputPort('SW1') p.queues = {None} p._M_Windows = np.array([[0, 0, 100]]) p._free_period = 100 p.dq_modify_period(True) self.assertEqual(p._free_period, 50) p.dq_modify_period(False) self.assertEqual(p._free_period, 75) p.dq_modify_period(True) self.assertEqual(p._free_period, 62) p.dq_modify_period(True) self.assertEqual(p._free_period, 56) p.dq_modify_period(False) self.assertEqual(p._free_period, 59) self.assertEqual(p.dq_modify_period(True), True)
def test_dq_period_lower(self): p = OutputPort('SW1') p.queues = {None} p._M_Windows = np.array([[0, 0, 100]]) p._free_period = 100 p.dq_modify_period(True) self.assertEqual(p._free_period, 50) p.dq_modify_period(True) self.assertEqual(p._free_period, 25) p.dq_modify_period(True) self.assertEqual(p._free_period, 12) p.dq_modify_period(True) self.assertEqual(p._free_period, 6) p.dq_modify_period(True) self.assertEqual(p._free_period, 3) p.dq_modify_period(True) self.assertEqual(p._free_period, 1) p.dq_modify_period(True) self.assertEqual(p._free_period, 0) p.dq_modify_period(True) self.assertEqual(p._free_period, 0) self.assertEqual(p.dq_modify_period(True), False)