update pre-commit config
This commit is contained in:
1 parent
cb78206c2d
commit
0f9e295ba3
3 files changed
+64
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import unittest
|
||||
from spotiplayer_pi.main import parse_config
|
||||
from spotiplayer_pi.api import Api
|
||||
|
||||
|
||||
class TestApp(unittest.TestCase):
|
||||
def test_config(self):
|
||||
self.cfg = parse_config()
|
||||
|
||||
# Assertions for config structure and values
|
||||
self.assertIsNotNone(self.cfg["refresh_token"])
|
||||
self.assertIsNotNone(self.cfg["base_64"])
|
||||
self.assertIsInstance(self.cfg["api_interval"], (int, float))
|
||||
self.assertGreater(self.cfg["api_interval"], 0)
|
||||
self.assertIsInstance(self.cfg["refresh_interval"], (int, float))
|
||||
self.assertGreater(self.cfg["refresh_interval"], 0)
|
||||
self.assertIn("color_theme", self.cfg)
|
||||
|
||||
# Check color_theme structure
|
||||
color_theme = self.cfg["color_theme"]
|
||||
self.assertIsInstance(color_theme, dict)
|
||||
for key in ["text", "bar_outline", "bar_inside", "background"]:
|
||||
self.assertIn(key, color_theme)
|
||||
self.assertIsInstance(color_theme[key], tuple)
|
||||
self.assertEqual(len(color_theme[key]), 3)
|
||||
self.assertTrue(
|
||||
all(isinstance(c, int) and 0 <= c <= 255 for c in color_theme[key])
|
||||
)
|
||||
|
||||
def test_refreshAuth(self):
|
||||
self.cfg = parse_config()
|
||||
self.api = Api(self.cfg["refresh_token"], self.cfg["base_64"])
|
||||
expires_in = self.api.refreshAuth()
|
||||
|
||||
self.assertIsNotNone(self.api.access_token)
|
||||
self.assertIsNotNone(expires_in)
|
||||
self.assertGreater(expires_in, 0)
|
||||
self.assertIn("Authorization", self.api.header)
|
||||
|
||||
def test_getPlaying(self):
|
||||
self.cfg = parse_config()
|
||||
self.api = Api(self.cfg["refresh_token"], self.cfg["base_64"])
|
||||
self.api.refreshAuth()
|
||||
|
||||
result = self.api.getPlaying()
|
||||
if result != "not-playing":
|
||||
self.assertIsNotNone(result)
|
||||
self.assertIn("track", result)
|
||||
self.assertIn("album", result)
|
||||
self.assertIn("artists", result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user