def test_RGBListHasBlankInFront(self): mock_pressureHistory = mock.create_autospec(PressureHistory) mock_pressureHistory.normalized.return_value = ( 0, ) * PressureHistory.MAXLEN ledAdapter = LEDMatrixAdapter(mock_pressureHistory) self.assertEqual(ledAdapter.asHatRGBList()[0], (0, 0, 0))
def test_RGBListIs64ElementsLong(self): mock_pressureHistory = mock.create_autospec(PressureHistory) mock_pressureHistory.normalized.return_value = ( 0, ) * PressureHistory.MAXLEN ledAdapter = LEDMatrixAdapter(mock_pressureHistory) self.assertEqual(len(ledAdapter.asHatRGBList()), 64)
def testHueListMapsNoneToNone(self): mock_pressureHistory = mock.create_autospec(PressureHistory) mock_pressureHistory.normalized.return_value = (None, ) ledAdapter = LEDMatrixAdapter(mock_pressureHistory) hueList = ledAdapter.asHueList() self.assertEqual(hueList, (None, ))
def test_hueListIsInRedBlueRange(self): mock_pressureHistory = mock.create_autospec(PressureHistory) mock_pressureHistory.normalized.return_value = (0, 1) ledAdapter = LEDMatrixAdapter(mock_pressureHistory) hueList = ledAdapter.asHueList() self.assertEqual(hueList, (ledAdapter.MINHUE, ledAdapter.MAXHUE))
def test_extermeNormalizedPressuresResultInRedToBlueWithBlankInFront(self): mock_pressureHistory = mock.create_autospec(PressureHistory) mock_pressureHistory.normalized.return_value = (0, 1) ledAdapter = LEDMatrixAdapter(mock_pressureHistory) self.assertEqual(ledAdapter.asHatRGBList(), ((0, 0, 0), (255, 0, 0), (0, 0, 255)))
def test_normalRangeTo255Range(self): self.assertEqual(LEDMatrixAdapter.to255Range((0, 0.5, 1)), (int(0), int(0.5 * 255), int(255)))
def test_hueListretrievesNormalizedHistory(self): mock_pressureHistory = mock.create_autospec(PressureHistory) ledAdapter = LEDMatrixAdapter(mock_pressureHistory) ledAdapter.asHueList() self.assertTrue(mock_pressureHistory.normalized.called, "Didn't get the normalized pressure history")