test(worker): setup testing
This commit is contained in:
parent
ab6cebb6ed
commit
7184fb3235
5 changed files with 38 additions and 2 deletions
25
worker/tests/tasks_test.py
Normal file
25
worker/tests/tasks_test.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
from requests import Response
|
||||
|
||||
from libretime_worker.tasks import extract_filename
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url, header, expected",
|
||||
[
|
||||
("http://example.com/from-url.mp3", None, "from-url.mp3"),
|
||||
(
|
||||
"http://example.com/from-url.mp3",
|
||||
'attachment; filename="from-header.mp3"',
|
||||
"from-header.mp3",
|
||||
),
|
||||
("http://example.com/from-url.mp3", "attachment", "from-url.mp3"),
|
||||
],
|
||||
)
|
||||
def test_extract_filename(url, header, expected):
|
||||
resp = Response()
|
||||
resp.url = url
|
||||
if header is not None:
|
||||
resp.headers["Content-Disposition"] = header
|
||||
|
||||
assert extract_filename(resp) == expected
|
Loading…
Add table
Add a link
Reference in a new issue