fediplug/test_fediplay.py

23 lines
1.2 KiB
Python
Raw Normal View History

2018-01-27 02:49:45 +01:00
from os import environ
2018-03-18 01:05:16 +01:00
from fediplay.mastodon import extract_links
from fediplay.queue import build_play_command
2018-01-27 02:19:25 +01:00
2018-07-20 17:25:41 +02:00
2018-01-27 02:19:25 +01:00
def test_extract_links():
toot = {
'content': "<p><a href=\"https://cybre.space/tags/nowplaying\" class=\"mention hashtag\" rel=\"tag\">#<span>nowplaying</span></a> <a href=\"https://cybre.space/tags/fediplay\" class=\"mention hashtag\" rel=\"tag\">#<span>fediplay</span></a> Grimes ft. Janelle Mon\u00e1e - Venus Fly <a href=\"https://www.youtube.com/watch?v=eTLTXDHrgtw\" rel=\"nofollow noopener\" target=\"_blank\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">youtube.com/watch?v=eTLTXDHrgt</span><span class=\"invisible\">w</span></a></p>"
}
2018-03-18 01:05:16 +01:00
urls = extract_links(toot)
2018-01-27 02:19:25 +01:00
assert urls == ['https://www.youtube.com/watch?v=eTLTXDHrgtw']
2018-01-27 02:49:45 +01:00
def test_build_play_command_default():
environ.pop('FEDIPLAY_PLAY_COMMAND')
2018-03-18 01:05:16 +01:00
play_command = build_play_command('Awesome Music.mp3')
2018-01-27 02:49:45 +01:00
assert play_command == 'ffplay -v 0 -nostats -hide_banner -autoexit -nodisp \'Awesome Music.mp3\''
def test_build_play_command_specified():
environ.update(FEDIPLAY_PLAY_COMMAND='afplay {filename}')
2018-03-18 01:05:16 +01:00
play_command = build_play_command('Awesome Music.mp3')
2018-01-27 02:49:45 +01:00
assert play_command == 'afplay \'Awesome Music.mp3\''