def test_cd_no_magazine(self): radio = Radio() # set up known values radio.operation_mode = OperationModes.CD_PLAYING radio.cd_disc = 5 radio.cd_track = 3 radio.cd_track_pos = 99 # parse display radio.parse(b"NO MAGAZIN") self.assertEqual(radio.cd_disc, 0) self.assertEqual(radio.cd_track, 0) self.assertEqual(radio.cd_track_pos, 0) self.assertEqual(radio.operation_mode, OperationModes.CD_NO_MAGAZINE) self.assertEqual(radio.display_mode, DisplayModes.SHOWING_OPERATION)
def test_cd_cdx_no_cd(self): radio = Radio() # set up known values radio.operation_mode = OperationModes.CD_PLAYING radio.cd_disc = 1 radio.cd_track = 3 radio.cd_track_pos = 99 # parse display radio.parse(b"CD 2 NO CD ") # space in "CD 2" self.assertEqual(radio.cd_disc, 2) self.assertEqual(radio.cd_track, 0) self.assertEqual(radio.cd_track_pos, 0) self.assertEqual(radio.operation_mode, OperationModes.CD_CDX_NO_CD) self.assertEqual(radio.display_mode, DisplayModes.SHOWING_OPERATION)
def test_cd_cdx_cd_err(self): displays = ( b"CD1 CD ERR ", # Premium 4 b"CD 1CD ERR ", # Premium 5 ) for display in displays: radio = Radio() # set up known values radio.operation_mode = OperationModes.CD_PLAYING radio.cd_disc = 5 radio.cd_track = 3 radio.cd_track_pos = 99 # parse display radio.parse(display) self.assertEqual(radio.cd_disc, 1) self.assertEqual(radio.cd_track, 0) self.assertEqual(radio.cd_track_pos, 0) self.assertEqual(radio.operation_mode, OperationModes.CD_CDX_CD_ERR) self.assertEqual(radio.display_mode, DisplayModes.SHOWING_OPERATION)
def test_cd_scanning(self): values = ( (b"SCANCD1TR04", 1, 4), (b"SCANCD3TR15", 3, 15), ) for display, disc, track in values: radio = Radio() # set up known values radio.operation_mode = OperationModes.CD_PLAYING radio.cd_disc = 5 radio.cd_track = 12 radio.cd_track_pos = 42 # parse display radio.parse(display) self.assertEqual(radio.cd_disc, disc) self.assertEqual(radio.cd_track, track) self.assertEqual(radio.cd_track_pos, 0) self.assertEqual(radio.operation_mode, OperationModes.CD_SCANNING) self.assertEqual(radio.display_mode, DisplayModes.SHOWING_OPERATION)