mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
# This file is part of Supysonic.
|
|
# Supysonic is a Python implementation of the Subsonic server API.
|
|
#
|
|
# Copyright (C) 2020 Alban 'spl0k' Féron
|
|
#
|
|
# Distributed under terms of the GNU AGPLv3 license.
|
|
|
|
from pony.orm import db_session
|
|
from threading import Thread
|
|
|
|
from supysonic.daemon.server import Daemon
|
|
from supysonic.db import Folder
|
|
|
|
from .apitestbase import ApiTestBase
|
|
|
|
|
|
class ScanTestCase(ApiTestBase):
|
|
def setUp(self):
|
|
super().setUp(apiVersion="1.16.0")
|
|
|
|
def test_unauthorized(self):
|
|
self._make_request("startScan", args={"u": "bob", "p": "B0b"}, error=50)
|
|
self._make_request("getScanStatus", args={"u": "bob", "p": "B0b"}, error=50)
|
|
|
|
def test_unavailable(self):
|
|
self._make_request("startScan", error=0)
|
|
self._make_request("getScanStatus", error=0)
|
|
|
|
|
|
class ScanWithDaemonTestCase(ApiTestBase):
|
|
def setUp(self):
|
|
super().setUp(apiVersion="1.16.0")
|
|
|
|
with db_session:
|
|
Folder(name="Root", root=True, path="tests/assets")
|
|
|
|
self._daemon = Daemon(self.config)
|
|
self._thread = Thread(target=self._daemon.run)
|
|
self._thread.start()
|
|
|
|
def tearDown(self):
|
|
self._daemon.terminate()
|
|
self._thread.join()
|
|
|
|
super().tearDown()
|
|
|
|
def test_startScan(self):
|
|
rv, child = self._make_request("startScan", tag="scanStatus")
|
|
self.assertEqual(child.get("scanning"), "true")
|
|
self.assertGreaterEqual(int(child.get("count")), 0)
|
|
|
|
def test_getScanStatus(self):
|
|
rv, child = self._make_request("getScanStatus", tag="scanStatus")
|
|
self.assertEqual(child.get("scanning"), "false")
|
|
self.assertEqual(int(child.get("count")), 0)
|