mock_dependent.MockDependent

Here are the examples of the python api mock_dependent.MockDependent taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

11 Examples 7

Example 1

Project: pydvbcss Source File: test_Clock.py
    def test_dependents(self):
        b = ClockBase()
        d1 = MockDependent()
        d2 = MockDependent()
        b.bind(d1)
        b.bind(d2)
        b.notify(None)
        d1.assertNotificationsEqual([b])
        d2.assertNotificationsEqual([b])
        
        b.unbind(d1)
        b.notify(None)
        d2.assertNotificationsEqual([b])
        d1.assertNotificationsEqual([])
        
        b.unbind(d2)
        b.notify(None)
        d1.assertNotificationsEqual([])
        d2.assertNotificationsEqual([])

Example 2

Project: pydvbcss Source File: test_Clock.py
    def test_changeCorrelationNotifies(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.correlation = Correlation(50,20)
        
        d1.assertNotNotified()
        d2.assertNotificationsEqual([c])
        d3.assertNotificationsEqual([cc])

Example 3

Project: pydvbcss Source File: test_Clock.py
    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])

Example 4

Project: pydvbcss Source File: test_Clock.py
    def test_setCorrelationAndSpeed(self):
        a = self.newSysClock(tickRate=1000000)
        b = CorrelatedClock(a, 1000, correlation=Correlation(0,0))
        b.speed = 1.0
        
        db = MockDependent()
        b.bind(db)
        
        b.setCorrelationAndSpeed(Correlation(5,0),2)
        db.assertNotificationsEqual([b])
        self.assertEqual(b.toParentTicks(10), 5005)

Example 5

Project: pydvbcss Source File: test_Clock.py
    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)

Example 6

Project: pydvbcss Source File: test_Clock.py
    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)

Example 7

Project: pydvbcss Source File: test_Clock.py
    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)

Example 8

Project: pydvbcss Source File: test_Clock.py
    def test_setParentNoChangeNoNotify(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(a)
        d.assertNotNotified()
        self.assertEquals(b.getParent(), a)

Example 9

Project: pydvbcss Source File: test_Clock.py
    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])

Example 10

Project: pydvbcss Source File: test_Clock.py
    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])            

Example 11

Project: pydvbcss Source File: test_Clock.py
    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])