def test_parentChangeCausesNotification(self): oc = OffsetClock(parentClock=self.parent, offset=0.040) dep = MockDependent() oc.bind(dep) dep.assertNotNotified() oc.setParent(self.altParent) dep.assertNotificationsEqual([oc])
def test_setParentNoChangeNoNotify(self): a = self.newSysClock(tickRate=1000) b = CorrelatedClock(a, 1000, correlation=Correlation(0, 0)) c = CorrelatedClock(a, 1000, correlation=Correlation(10, 0)) d = MockDependent() b.bind(d) d.assertNotNotified() b.setParent(a) d.assertNotNotified() self.assertEquals(b.getParent(), a)
def test_setParent(self): a = self.newSysClock(tickRate=1000) b = CorrelatedClock(a, 1000, correlation=Correlation(0, 0)) c = CorrelatedClock(a, 1000, correlation=Correlation(10, 0)) d = MockDependent() b.bind(d) d.assertNotNotified() b.setParent(c) d.assertNotificationsEqual([b]) self.assertEquals(b.getParent(), c)
def test_slewNotifiesDependents(self): mockTime = self.mockTime b = self.newSysClock() mockTime.timeNow = 5020.8 c = TunableClock(b, tickRate=1000, ticks=5) cc = TunableClock(c, tickRate=100) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) d1.assertNotNotified() d2.assertNotNotified() d3.assertNotNotified() c.slew = 100 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_slewNotifiesDependents(self): mockTime = self.mockTime mockTime.timeNow = 5020.8 b = SysClock() c = TunableClock(b, tickRate=1000, ticks=5) cc = TunableClock(c, tickRate=100) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) d1.assertNotNotified() d2.assertNotNotified() d3.assertNotNotified() c.slew = 100 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_setParent(self): a = self.newSysClock(tickRate=1000) b = RangeCorrelatedClock(a, 1000, correlation1=(100, 1000), correlation2=(200, 1110)) c = RangeCorrelatedClock(a, 1000, correlation1=(200, 1000), correlation2=(300, 1110)) d = MockDependent() b.bind(d) d.assertNotNotified() b.setParent(c) d.assertNotificationsEqual([b]) self.assertEquals(b.getParent(), c)
def test_changeSpeedeNotifies(self): """Check a change to the correlation propagates notifications to dependents of this clock""" b = self.newSysClock() c = CorrelatedClock(b, 1000, correlation=Correlation(0, 300)) cc = CorrelatedClock(c, 50) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) c.speed = 0.5 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_changeSpeedeNotifies(self): """Check a change to the correlation propagates notifications to dependents of this clock""" b = SysClock() c = CorrelatedClock(b, 1000, correlation=(0,300)) cc = CorrelatedClock(c, 50) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) c.speed = 0.5 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_changeFreqNotifies(self): mockTime = self.mockTime mockTime.timeNow = 5020.8 b = SysClock() c = CorrelatedClock(b, 1000, correlation=(50,300)) cc = CorrelatedClock(c, 50) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) c.tickRate = 500 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_changeFreqNotifies(self): mockTime = self.mockTime b = self.newSysClock() mockTime.timeNow = 5020.8 c = CorrelatedClock(b, 1000, correlation=Correlation(50, 300)) cc = CorrelatedClock(c, 50) d1 = MockDependent() d2 = MockDependent() d3 = MockDependent() b.bind(d1) c.bind(d2) cc.bind(d3) c.tickRate = 500 d1.assertNotNotified() d2.assertNotificationsEqual([c]) d3.assertNotificationsEqual([cc])
def test_availabilityPropagation(self): a = self.newSysClock() b = CorrelatedClock(a, 1000) c = CorrelatedClock(b, 2000) d = CorrelatedClock(c, 3000) da = MockDependent() db = MockDependent() dc = MockDependent() dd = MockDependent() a.bind(da) b.bind(db) c.bind(dc) d.bind(dd) self.assertTrue(a.isAvailable()) self.assertTrue(b.isAvailable()) self.assertTrue(c.isAvailable()) self.assertTrue(d.isAvailable()) c.setAvailability(False) self.assertTrue(a.isAvailable()) self.assertTrue(b.isAvailable()) self.assertFalse(c.isAvailable()) self.assertFalse(d.isAvailable()) da.assertNotNotified() db.assertNotNotified() dc.assertNotificationsEqual([c]) dd.assertNotificationsEqual([d]) d.setAvailability(False) self.assertTrue(a.isAvailable()) self.assertTrue(b.isAvailable()) self.assertFalse(c.isAvailable()) self.assertFalse(d.isAvailable()) da.assertNotNotified() db.assertNotNotified() dc.assertNotNotified() dd.assertNotNotified() c.setAvailability(True) self.assertTrue(a.isAvailable()) self.assertTrue(b.isAvailable()) self.assertTrue(c.isAvailable()) self.assertFalse(d.isAvailable()) da.assertNotNotified() db.assertNotNotified() dc.assertNotificationsEqual([c]) dd.assertNotificationsEqual([d])