Rename PlaybackState.position to time_position.

This commit is contained in:
Jens Luetjen 2016-04-01 19:13:26 +02:00
parent eb930a1679
commit cf5dfccee2
4 changed files with 14 additions and 14 deletions

View File

@ -602,7 +602,7 @@ class PlaybackController(object):
def _export_state(self): def _export_state(self):
return models.PlaybackState( return models.PlaybackState(
tlid=self.get_current_tlid(), tlid=self.get_current_tlid(),
position=self.get_time_position(), time_position=self.get_time_position(),
state=self.get_state()) state=self.get_state())
def _restore_state(self, state, coverage): def _restore_state(self, state, coverage):
@ -616,5 +616,5 @@ class PlaybackController(object):
if new_state == PlaybackState.PAUSED: if new_state == PlaybackState.PAUSED:
self._start_paused = True self._start_paused = True
if new_state in (PlaybackState.PLAYING, PlaybackState.PAUSED): if new_state in (PlaybackState.PLAYING, PlaybackState.PAUSED):
self._start_at_position = state.position self._start_at_position = state.time_position
self.play(tlid=state.tlid) self.play(tlid=state.tlid)

View File

@ -60,8 +60,8 @@ class PlaybackState(ValidatedImmutableObject):
:param tlid: current track tlid :param tlid: current track tlid
:type tlid: int :type tlid: int
:param position: play position :param time_position: play position
:type position: int :type time_position: int
:param state: playback state :param state: playback state
:type state: :class:`validation.PLAYBACK_STATES` :type state: :class:`validation.PLAYBACK_STATES`
""" """
@ -70,7 +70,7 @@ class PlaybackState(ValidatedImmutableObject):
tlid = fields.Integer(min=1) tlid = fields.Integer(min=1)
# The playback position. Read-only. # The playback position. Read-only.
position = fields.Integer(min=0) time_position = fields.Integer(min=0)
# The playback state. Read-only. # The playback state. Read-only.
state = fields.Field(choices=validation.PLAYBACK_STATES) state = fields.Field(choices=validation.PLAYBACK_STATES)

View File

@ -1141,7 +1141,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
self.replay_events() self.replay_events()
state = PlaybackState( state = PlaybackState(
position=0, state='playing', tlid=tl_tracks[1].tlid) time_position=0, state='playing', tlid=tl_tracks[1].tlid)
value = self.core.playback._export_state() value = self.core.playback._export_state()
self.assertEqual(state, value) self.assertEqual(state, value)
@ -1154,7 +1154,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
self.assertEqual('stopped', self.core.playback.get_state()) self.assertEqual('stopped', self.core.playback.get_state())
state = PlaybackState( state = PlaybackState(
position=0, state='playing', tlid=tl_tracks[2].tlid) time_position=0, state='playing', tlid=tl_tracks[2].tlid)
coverage = ['play-always'] coverage = ['play-always']
self.core.playback._restore_state(state, coverage) self.core.playback._restore_state(state, coverage)
self.replay_events() self.replay_events()
@ -1171,7 +1171,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
self.assertEqual('stopped', self.core.playback.get_state()) self.assertEqual('stopped', self.core.playback.get_state())
state = PlaybackState( state = PlaybackState(
position=0, state='playing', tlid=tl_tracks[2].tlid) time_position=0, state='playing', tlid=tl_tracks[2].tlid)
coverage = ['other'] coverage = ['other']
self.core.playback._restore_state(state, coverage) self.core.playback._restore_state(state, coverage)
self.replay_events() self.replay_events()

View File

@ -78,16 +78,16 @@ class MixerStateTest(unittest.TestCase):
class PlaybackStateTest(unittest.TestCase): class PlaybackStateTest(unittest.TestCase):
def test_position(self): def test_position(self):
position = 123456 time_position = 123456
result = PlaybackState(position=position) result = PlaybackState(time_position=time_position)
self.assertEqual(result.position, position) self.assertEqual(result.time_position, time_position)
with self.assertRaises(AttributeError): with self.assertRaises(AttributeError):
result.position = None result.time_position = None
def test_position_invalid(self): def test_position_invalid(self):
position = -1 time_position = -1
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
PlaybackState(position=position) PlaybackState(time_position=time_position)
def test_tl_track(self): def test_tl_track(self):
tlid = 42 tlid = 42