def test_regular_play_states(self): self.assertEqual(const.PLAY_STATE_LOADING, convert.playstate(PLAY_STATE_LOADING)) self.assertEqual(const.PLAY_STATE_PAUSED, convert.playstate(PLAY_STATE_PAUSED)) self.assertEqual(const.PLAY_STATE_PLAYING, convert.playstate(PLAY_STATE_PLAYING)) self.assertEqual(const.PLAY_STATE_FAST_FORWARD, convert.playstate(PLAY_STATE_FORWARD)) self.assertEqual(const.PLAY_STATE_FAST_BACKWARD, convert.playstate(PLAY_STATE_BACKWARD))
def test_play_state_no_media(self): # This test should not really be here as "None" is in reality not a # valid value. But it is supported nonetheless because that makes # usage nicer. None means that the field is not included in a # server response, which matches the behavior of dmap.first. self.assertEqual(const.PLAY_STATE_NO_MEDIA, convert.playstate(None))
def test_regular_playstates(self): self.assertEqual(DeviceState.Idle, convert.playstate(PLAY_STATE_IDLE)) self.assertEqual(DeviceState.Loading, convert.playstate(PLAY_STATE_LOADING)) self.assertEqual(DeviceState.Stopped, convert.playstate(PLAY_STATE_STOPPED)) self.assertEqual(DeviceState.Paused, convert.playstate(PLAY_STATE_PAUSED)) self.assertEqual(DeviceState.Playing, convert.playstate(PLAY_STATE_PLAYING)) self.assertEqual(DeviceState.Seeking, convert.playstate(PLAY_STATE_FORWARD)) self.assertEqual(DeviceState.Seeking, convert.playstate(PLAY_STATE_BACKWARD))
def test_unknown_playstate_throws(self): with self.assertRaises(exceptions.UnknownPlayState): convert.playstate(99999)
def play_state(self): """Play state, e.g. playing or paused.""" state = dmap.first(self.playstatus, 'cmst', 'caps') return convert.playstate(state)
def device_state(self): """Device state, e.g. playing or paused.""" state = parser.first(self.playstatus, 'cmst', 'caps') return convert.playstate(state)