Skip to content

Commit

Permalink
added unit tests for checking audio url
Browse files Browse the repository at this point in the history
  • Loading branch information
porschelab committed Oct 13, 2019
1 parent be22c3a commit c8a891c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions panel/tests/widgets/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ def test_audio_array(document, comm):

assert widget_value.split(',')[1] == b64_encoded
assert widget.value.startswith('data:audio/wav;base64')


def test_audio_url(document, comm):
audio_url = 'http://ccrma.stanford.edu/~jos/mp3/pno-cs.mp3'
audio2 = Audio(name='Audio', value=audio_url)
url_widget = audio2.get_root(document, comm=comm)

assert audio_url == url_widget.value

2 changes: 2 additions & 0 deletions panel/widgets/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def _process_param_change(self, msg):
with open(value, 'rb') as f:
data = f.read()
data = b64encode(data)
elif str.lower(value).startswith('http'):
return msg
elif not value:
data, fmt = b'', 'wav'
else:
Expand Down

0 comments on commit c8a891c

Please sign in to comment.