feat(api): add /info and /stream/* endpoints
This commit is contained in:
parent
5bf62dd9cb
commit
12d2d4b15a
15 changed files with 324 additions and 173 deletions
|
@ -0,0 +1,31 @@
|
|||
from libretime_api.core.models.preference import Preference
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_preference_get_site_preferences(db):
|
||||
result = Preference.get_site_preferences()
|
||||
assert result.dict() == {
|
||||
"station_name": "LibreTime",
|
||||
}
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_preference_get_stream_preferences(db):
|
||||
result = Preference.get_stream_preferences()
|
||||
assert result.dict() == {
|
||||
"input_fade_transition": 0.0,
|
||||
"message_format": 0,
|
||||
"message_offline": "LibreTime - offline",
|
||||
}
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_preference_get_stream_state(db):
|
||||
result = Preference.get_stream_state()
|
||||
assert result.dict() == {
|
||||
"input_main_connected": False,
|
||||
"input_main_streaming": False,
|
||||
"input_show_connected": False,
|
||||
"input_show_streaming": False,
|
||||
"schedule_streaming": True,
|
||||
}
|
19
api/libretime_api/core/tests/views/test_info.py
Normal file
19
api/libretime_api/core/tests/views/test_info.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from rest_framework.test import APIClient
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_version_get(db, api_client: APIClient):
|
||||
response = api_client.get("/api/v2/version")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"api_version": "2.0.0",
|
||||
}
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_info_get(db, api_client: APIClient):
|
||||
response = api_client.get("/api/v2/info")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"station_name": "LibreTime",
|
||||
}
|
25
api/libretime_api/core/tests/views/test_stream.py
Normal file
25
api/libretime_api/core/tests/views/test_stream.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from rest_framework.test import APIClient
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_stream_preferences_get(db, api_client: APIClient):
|
||||
response = api_client.get("/api/v2/stream/preferences")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"input_fade_transition": 0.0,
|
||||
"message_format": 0,
|
||||
"message_offline": "LibreTime - offline",
|
||||
}
|
||||
|
||||
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
def test_stream_state_get(db, api_client: APIClient):
|
||||
response = api_client.get("/api/v2/stream/state")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"input_main_connected": False,
|
||||
"input_main_streaming": False,
|
||||
"input_show_connected": False,
|
||||
"input_show_streaming": False,
|
||||
"schedule_streaming": True,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue