e2e(api): add initial functional tests & pytest configuration
Build Debian Package / build (push) Successful in 8s
Build Debian Package / build (push) Successful in 8s
Signed-off-by: Arian Nasr <arian@2ari.ca>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
Werkzeug==3.1.8
|
||||
pytest==9.0.3
|
||||
requests==2.34.2
|
||||
@@ -0,0 +1,22 @@
|
||||
import pytest
|
||||
import requests
|
||||
import io
|
||||
import os
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
def test_api_ping(base_url):
|
||||
response = requests.get(f'{base_url}/ping')
|
||||
assert response.status_code == 200
|
||||
assert response.text == 'pong'
|
||||
|
||||
def test_api_upload_non_audio_file(base_url, upload_folder):
|
||||
files = {'file': ('test.txt', io.BytesIO(b'not an audio file'))}
|
||||
expected_filename = os.path.join(upload_folder, secure_filename('test.txt'))
|
||||
response = requests.post(f'{base_url}/', files=files)
|
||||
assert response.status_code == 400
|
||||
assert "not allowed" in response.json().get("error", "")
|
||||
assert not os.path.exists(expected_filename)
|
||||
|
||||
if os.path.exists(expected_filename):
|
||||
os.remove(expected_filename)
|
||||
@@ -0,0 +1,10 @@
|
||||
import pytest
|
||||
import os
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def base_url():
|
||||
return os.getenv('BASE_URL', 'http://127.0.0.1:5001')
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def upload_folder():
|
||||
return os.getenv('NAVIDROME_MUSIC_FOLDER', '/opt/navidrome/music')
|
||||
Reference in New Issue
Block a user