[html] Properly display them
Some checks failed
Some checks failed
This commit is contained in:
@ -217,8 +217,9 @@ class RefreshHandler(tornado.web.RequestHandler):
|
|||||||
|
|
||||||
|
|
||||||
class StatusHandler(tornado.web.RequestHandler):
|
class StatusHandler(tornado.web.RequestHandler):
|
||||||
def initialize(self, core: CoreProxy) -> None:
|
def initialize(self, core: CoreProxy, prefix: str) -> None:
|
||||||
self.core = core
|
self.core = core
|
||||||
|
self.prefix = prefix
|
||||||
|
|
||||||
def get(self) -> None:
|
def get(self) -> None:
|
||||||
try:
|
try:
|
||||||
@ -233,7 +234,7 @@ class StatusHandler(tornado.web.RequestHandler):
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
result_typed = cast("list[Playlist]", result)
|
result_typed = cast("list[Playlist]", result)
|
||||||
smart = [p for p in result_typed if p.uri and "smartplaylists" in p.uri]
|
smart = [p for p in result_typed if p.name and p.name.startswith(self.prefix)]
|
||||||
self.write(
|
self.write(
|
||||||
{
|
{
|
||||||
"smart_playlists": [
|
"smart_playlists": [
|
||||||
@ -269,5 +270,5 @@ def app_factory(config: Config, core: CoreProxy) -> list[tuple]:
|
|||||||
(r"/instant-mix", InstantMixHandler,
|
(r"/instant-mix", InstantMixHandler,
|
||||||
{"core": core, "prefix": prefix, "uris": uris}),
|
{"core": core, "prefix": prefix, "uris": uris}),
|
||||||
(r"/refresh", RefreshHandler, {"core": core, "config": config}),
|
(r"/refresh", RefreshHandler, {"core": core, "config": config}),
|
||||||
(r"/status", StatusHandler, {"core": core}),
|
(r"/status", StatusHandler, {"core": core, "prefix": prefix}),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -250,7 +250,7 @@ class TestStatusHandler:
|
|||||||
|
|
||||||
app = tornado.web.Application(
|
app = tornado.web.Application(
|
||||||
[
|
[
|
||||||
(r"/status", StatusHandler, {"core": core}),
|
(r"/status", StatusHandler, {"core": core, "prefix": "[Smart]"}),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
request = tornado.httputil.HTTPServerRequest(
|
request = tornado.httputil.HTTPServerRequest(
|
||||||
@ -260,7 +260,7 @@ class TestStatusHandler:
|
|||||||
connection=mock.Mock(),
|
connection=mock.Mock(),
|
||||||
headers=tornado.httputil.HTTPHeaders(),
|
headers=tornado.httputil.HTTPHeaders(),
|
||||||
)
|
)
|
||||||
handler = StatusHandler(app, request, core=core)
|
handler = StatusHandler(app, request, core=core, prefix="[Smart]")
|
||||||
handler.write = mock.Mock()
|
handler.write = mock.Mock()
|
||||||
handler.get()
|
handler.get()
|
||||||
data = handler.write.call_args[0][0]
|
data = handler.write.call_args[0][0]
|
||||||
|
|||||||
Reference in New Issue
Block a user