def test_tunerlist_releaseTuner_invalid(self): tunerList = TunerList(tunerList=[self.tunerB, self.tunerC]) self.assertEqual(tunerList.tuners, [self.tunerB, self.tunerC]) self.assertFalse(tunerList.lockedTuners) tunerList.releaseTuner(self.tunerA) # not managed by tunerList self.assertEqual(tunerList.tuners, [self.tunerB, self.tunerC]) self.assertFalse(tunerList.lockedTuners)
def test_tunerlist_releaseTuner_notLocked(self): tunerList = TunerList(tunerList=[self.tunerA, self.tunerB, self.tunerC]) self.assertEqual(self.tunerA, tunerList.lockTuner()) self.assertEqual(self.tunerB, tunerList.lockTuner()) self.assertEqual(tunerList.tuners, [self.tunerC]) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB]) tunerList.releaseTuner(self.tunerC) # tunerC is not locked! self.assertEqual(tunerList.tuners, [self.tunerC]) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB])
def test_tunerlist_lockTuner(self): tuners = [ self.tunerA, self.tunerB, self.tunerC] tunerList = TunerList(tuners) lockedTuner = tunerList.lockTuner() self.assertEqual(self.tunerA, lockedTuner) self.assertEqual(2, len(tunerList.tuners)) self.assertEqual(self.tunerB, tunerList.tuners[0]) self.assertEqual(self.tunerC, tunerList.tuners[1]) self.assertEqual(1, len(tunerList.lockedTuners)) self.assertEqual(self.tunerA, tunerList.lockedTuners[0])
def test_tunerlist_releaseTuner_notLocked(self): tunerList = TunerList( tunerList=[self.tunerA, self.tunerB, self.tunerC]) self.assertEqual(self.tunerA, tunerList.lockTuner()) self.assertEqual(self.tunerB, tunerList.lockTuner()) self.assertEqual(tunerList.tuners, [self.tunerC]) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB]) tunerList.releaseTuner(self.tunerC) # tunerC is not locked! self.assertEqual(tunerList.tuners, [self.tunerC]) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB])
def test_tunerlist_lockTuner(self): tuners = [self.tunerA, self.tunerB, self.tunerC] tunerList = TunerList(tuners) lockedTuner = tunerList.lockTuner() self.assertEqual(self.tunerA, lockedTuner) self.assertEqual(2, len(tunerList.tuners)) self.assertEqual(self.tunerB, tunerList.tuners[0]) self.assertEqual(self.tunerC, tunerList.tuners[1]) self.assertEqual(1, len(tunerList.lockedTuners)) self.assertEqual(self.tunerA, tunerList.lockedTuners[0])
def test_tunerlist_releaseTuner(self): tunerList = TunerList([]) tunerList.tuners = [self.tunerB, self.tunerA] tunerList.lockedTuners = [self.tunerE, self.tunerC, self.tunerD] tunerList.releaseTuner(self.tunerC) self.assertEqual(3, len(tunerList.tuners)) self.assertEqual(self.tunerB, tunerList.tuners[0]) self.assertEqual(self.tunerA, tunerList.tuners[1]) self.assertEqual(self.tunerC, tunerList.tuners[2]) self.assertEqual(2, len(tunerList.lockedTuners)) self.assertEqual(self.tunerE, tunerList.lockedTuners[0]) self.assertEqual(self.tunerD, tunerList.lockedTuners[1])
def test_tunerlist_complexTest(self): tunerList = TunerList(tunerList=[self.tunerA, self.tunerB, self.tunerC, self.tunerD]) self.assertEqual(self.tunerA, tunerList.lockTuner()) self.assertEqual(self.tunerB, tunerList.lockTuner()) self.assertEqual(self.tunerC, tunerList.lockTuner()) self.assertEqual(self.tunerD, tunerList.lockTuner()) self.assertIsNone(tunerList.lockTuner()) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB, self.tunerC, self.tunerD]) tunerList.releaseTuner(self.tunerE) # not managed by tunerList tunerList.releaseTuner(self.tunerC) tunerList.releaseTuner(self.tunerB) self.assertEqual(tunerList.tuners, [self.tunerC, self.tunerB]) self.assertEqual(self.tunerC, tunerList.lockTuner()) tunerList.releaseTuner(self.tunerA) tunerList.releaseTuner(self.tunerD) tunerList.releaseTuner(self.tunerC) self.assertFalse(tunerList.lockedTuners) self.assertEqual(tunerList.tuners, [self.tunerB, self.tunerA, self.tunerD, self.tunerC])
def test_tunerlist_complexTest(self): tunerList = TunerList( tunerList=[self.tunerA, self.tunerB, self.tunerC, self.tunerD]) self.assertEqual(self.tunerA, tunerList.lockTuner()) self.assertEqual(self.tunerB, tunerList.lockTuner()) self.assertEqual(self.tunerC, tunerList.lockTuner()) self.assertEqual(self.tunerD, tunerList.lockTuner()) self.assertIsNone(tunerList.lockTuner()) self.assertEqual(tunerList.lockedTuners, [self.tunerA, self.tunerB, self.tunerC, self.tunerD]) tunerList.releaseTuner(self.tunerE) # not managed by tunerList tunerList.releaseTuner(self.tunerC) tunerList.releaseTuner(self.tunerB) self.assertEqual(tunerList.tuners, [self.tunerC, self.tunerB]) self.assertEqual(self.tunerC, tunerList.lockTuner()) tunerList.releaseTuner(self.tunerA) tunerList.releaseTuner(self.tunerD) tunerList.releaseTuner(self.tunerC) self.assertFalse(tunerList.lockedTuners) self.assertEqual(tunerList.tuners, [self.tunerB, self.tunerA, self.tunerD, self.tunerC])