mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 02:29:24 +00:00
renamed django app folder to backend
This commit is contained in:
0
backend/playlist/tests/test_src/__init__.py
Normal file
0
backend/playlist/tests/test_src/__init__.py
Normal file
30
backend/playlist/tests/test_src/test_query_building.py
Normal file
30
backend/playlist/tests/test_src/test_query_building.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""test playlist query building"""
|
||||
|
||||
import pytest
|
||||
from playlist.src.query_building import QueryBuilder
|
||||
|
||||
|
||||
def test_build_data():
|
||||
"""test for correct key building"""
|
||||
qb = QueryBuilder(
|
||||
channel=["test_channel"],
|
||||
subscribed=["true"],
|
||||
type=["regular"],
|
||||
)
|
||||
result = qb.build_data()
|
||||
must_list = result["query"]["bool"]["must"]
|
||||
assert "query" in result
|
||||
assert "sort" in result
|
||||
assert result["sort"] == [{"playlist_name.keyword": {"order": "asc"}}]
|
||||
assert {"match": {"playlist_channel_id": "test_channel"}} in must_list
|
||||
assert {"match": {"playlist_subscribed": True}} in must_list
|
||||
|
||||
|
||||
def test_parse_type():
|
||||
"""validate type"""
|
||||
qb = QueryBuilder(type=["regular"])
|
||||
with pytest.raises(ValueError):
|
||||
qb.parse_type("invalid")
|
||||
|
||||
result = qb.parse_type("custom")
|
||||
assert result == {"match": {"playlist_type.keyword": "custom"}}
|
||||
Reference in New Issue
Block a user