diff --git a/.travis.yml b/.travis.yml index 85cae3a..2e10b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,7 @@ python: - 3.7 install: - pip install -r travis-requirements.txt -script: coverage run setup.py test +script: + - coverage run setup.py test + - coverage run setup.py test --test-suite tests.api.test_lyrics after_script: codecov diff --git a/tests/api/test_lyrics.py b/tests/api/test_lyrics.py new file mode 100644 index 0000000..bed1df2 --- /dev/null +++ b/tests/api/test_lyrics.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# coding: utf-8 +# +# This file is part of Supysonic. +# Supysonic is a Python implementation of the Subsonic server API. +# +# Copyright (C) 2017 Alban 'spl0k' FĂ©ron +# +# Distributed under terms of the GNU AGPLv3 license. + +import flask.json +import requests + +from .apitestbase import ApiTestBase + + +class LyricsTestCase(ApiTestBase): + def test_get_lyrics(self): + self._make_request("getLyrics", error=10) + self._make_request("getLyrics", {"artist": "artist"}, error=10) + self._make_request("getLyrics", {"title": "title"}, error=10) + + # Potentially skip the tests if ChartLyrics is down (which happens quite often) + try: + requests.get("http://api.chartlyrics.com/", timeout=5) + except requests.exceptions.Timeout: + self.skipTest("ChartLyrics down") + + rv, child = self._make_request( + "getLyrics", + { + "artist": "some really long name hoping", + "title": "to get absolutely no result", + }, + tag="lyrics", + ) + self.assertIsNone(child.text) + + # ChartLyrics + rv, child = self._make_request( + "getLyrics", + {"artist": "The Clash", "title": "London Calling"}, + tag="lyrics", + ) + self.assertIn("live by the river", child.text) + # ChartLyrics, JSON format + args = { + "u": "alice", + "p": "Alic3", + "c": "tests", + "f": "json", + "artist": "The Clash", + "title": "London Calling", + } + rv = self.client.get("/rest/getLyrics.view", query_string=args) + json = flask.json.loads(rv.data) + self.assertIn("value", json["subsonic-response"]["lyrics"]) + self.assertIn("live by the river", json["subsonic-response"]["lyrics"]["value"]) + + # Local file + rv, child = self._make_request( + "getLyrics", {"artist": "artist", "title": "23bytes"}, tag="lyrics" + ) + self.assertIn("null", child.text) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/api/test_media.py b/tests/api/test_media.py index 397fca0..42c14e3 100644 --- a/tests/api/test_media.py +++ b/tests/api/test_media.py @@ -8,9 +8,7 @@ # # Distributed under terms of the GNU AGPLv3 license. -import flask.json import os.path -import requests import uuid from io import BytesIO @@ -186,54 +184,6 @@ class MediaTestCase(ApiTestBase): self.assertEqual(im.format, "PNG") self.assertEqual(im.size, (120, 120)) - def test_get_lyrics(self): - self._make_request("getLyrics", error=10) - self._make_request("getLyrics", {"artist": "artist"}, error=10) - self._make_request("getLyrics", {"title": "title"}, error=10) - - # Potentially skip the tests if ChartLyrics is down (which happens quite often) - try: - requests.get("http://api.chartlyrics.com/", timeout=5) - except requests.exceptions.Timeout: - self.skipTest("ChartLyrics down") - - rv, child = self._make_request( - "getLyrics", - { - "artist": "some really long name hoping", - "title": "to get absolutely no result", - }, - tag="lyrics", - ) - self.assertIsNone(child.text) - - # ChartLyrics - rv, child = self._make_request( - "getLyrics", - {"artist": "The Clash", "title": "London Calling"}, - tag="lyrics", - ) - self.assertIn("live by the river", child.text) - # ChartLyrics, JSON format - args = { - "u": "alice", - "p": "Alic3", - "c": "tests", - "f": "json", - "artist": "The Clash", - "title": "London Calling", - } - rv = self.client.get("/rest/getLyrics.view", query_string=args) - json = flask.json.loads(rv.data) - self.assertIn("value", json["subsonic-response"]["lyrics"]) - self.assertIn("live by the river", json["subsonic-response"]["lyrics"]["value"]) - - # Local file - rv, child = self._make_request( - "getLyrics", {"artist": "artist", "title": "23bytes"}, tag="lyrics" - ) - self.assertIn("null", child.text) - def test_get_avatar(self): self._make_request("getAvatar", error=0)