From 1cfca9410938e5f4aa518deb13f47493cf9185c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Mon, 1 Apr 2024 12:33:57 +0200 Subject: [PATCH] Move a ListenBrainz test to the net suite Allow to uncomment it and slightly improves coverage --- tests/frontend/test_user.py | 12 ------------ tests/net/test_listenbrainz.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/frontend/test_user.py b/tests/frontend/test_user.py index dff2f5f..d65b1dc 100644 --- a/tests/frontend/test_user.py +++ b/tests/frontend/test_user.py @@ -255,18 +255,6 @@ class UserTestCase(FrontendTestBase): rv = self.client.get("/user/me/lastfm/unlink", follow_redirects=True) self.assertIn("Unlinked", rv.data) - def test_listenbrainz_link(self): - self._login("alice", "Alic3") - rv = self.client.get("/user/me/listenbrainz/link", follow_redirects=True) - self.assertIn("Missing ListenBrainz auth token", rv.data) - # # Testing this requires an HTTP request! - # rv = self.client.get( - # "/user/me/listenbrainz/link", - # query_string={"token": "abcdef"}, - # follow_redirects=True, - # ) - # self.assertIn("Error: ", rv.data) - def test_listenbrainz_unlink(self): self._login("alice", "Alic3") rv = self.client.get("/user/me/listenbrainz/unlink", follow_redirects=True) diff --git a/tests/net/test_listenbrainz.py b/tests/net/test_listenbrainz.py index abd2031..6486ad1 100644 --- a/tests/net/test_listenbrainz.py +++ b/tests/net/test_listenbrainz.py @@ -11,6 +11,8 @@ import unittest from supysonic.listenbrainz import ListenBrainz +from ..frontend.frontendtestbase import FrontendTestBase + class ListenBrainzTestCase(unittest.TestCase): """Basic test of unauthenticated ListenBrainz API method""" @@ -22,5 +24,18 @@ class ListenBrainzTestCase(unittest.TestCase): rv = listenbrainz._ListenBrainz__api_request(False, "/1/search/users/?search_term={0}".format(user), token="123") self.assertIsInstance(rv, dict) +class FrontendListenBrainzCase(FrontendTestBase): + def test_listenbrainz_link(self): + self._login("alice", "Alic3") + rv = self.client.get("/user/me/listenbrainz/link", follow_redirects=True) + self.assertIn("Missing ListenBrainz auth token", rv.data) + rv = self.client.get( + "/user/me/listenbrainz/link", + query_string={"token": "abcdef"}, + follow_redirects=True, + ) + self.assertIn("Error: ", rv.data) + + if __name__ == "__main__": unittest.main()