From 25624552349cbd159d2524911ae56f8c8348bfd7 Mon Sep 17 00:00:00 2001 From: Bruce Zhang Date: Tue, 9 May 2023 20:26:49 +0800 Subject: [PATCH] ci: add tests --- tests/test_nowplaying.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/test_nowplaying.py b/tests/test_nowplaying.py index 455384b..9840ad2 100644 --- a/tests/test_nowplaying.py +++ b/tests/test_nowplaying.py @@ -13,9 +13,9 @@ class NowPlayingInterface(aionp.NowPlayingInterface): def __init__(self): super().__init__(self.NAME) - def update_playback_mode(self): - self.set_playback_property(PlayProp.LoopStatus, aionp.LoopStatus.Playlist) - self.set_playback_property(PlayProp.Shuffle, True) + def update_playback_mode(self, loop_status: aionp.LoopStatus, shuffle: bool): + self.set_playback_property(PlayProp.LoopStatus, loop_status) + self.set_playback_property(PlayProp.Shuffle, shuffle) def update_song_props(self, meta: dict): metadata = aionp.PlaybackProperties.MetadataBean() @@ -30,8 +30,8 @@ def update_song_props(self, meta: dict): def update_position(self, position): self.set_playback_property(PlayProp.Position, int(position * 1000)) - def update_playback_status(self): - self.set_playback_property(PlayProp.PlaybackStatus, aionp.PlaybackStatus.Playing) + def update_playback_status(self, status: aionp.PlaybackStatus): + self.set_playback_property(PlayProp.PlaybackStatus, status) def on_play(self): print('on_play') @@ -70,3 +70,26 @@ async def test_update_song_props(server: NowPlayingInterface): 'artists': ["hello world"], 'album': 'Hello World' }) + + +async def test_update_position(server: NowPlayingInterface): + server.update_position(20) + + +async def test_update_playback_status(server: NowPlayingInterface): + server.update_playback_status(aionp.PlaybackStatus.Playing) + + +async def test_update_playback_mode(server: NowPlayingInterface): + server.update_playback_mode(aionp.LoopStatus.Playlist, True) + server.update_playback_mode(aionp.LoopStatus.Track, False) + server.update_playback_mode(aionp.LoopStatus.None_, False) + + +async def test_update_properties(server: NowPlayingInterface): + server.set_property(aionp.PropertyName.CanQuit, True) + server.set_property(aionp.PropertyName.CanRaise, True) + server.set_property(aionp.PropertyName.CanSetFullscreen, True) + server.set_property(aionp.PropertyName.Fullscreen, True) + server.set_property(aionp.PropertyName.SupportedMimeTypes, ['audio/mpeg']) + server.set_property(aionp.PropertyName.SupportedUriSchemes, ['aionp:'])