Skip to content

Commit

Permalink
Move a ListenBrainz test to the net suite
Browse files Browse the repository at this point in the history
Allow to uncomment it and slightly improves coverage
  • Loading branch information
spl0k committed Apr 1, 2024
1 parent 8d3a31d commit 1cfca94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 0 additions & 12 deletions tests/frontend/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,6 @@ def test_lastfm_unlink(self):
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)
Expand Down
15 changes: 15 additions & 0 deletions tests/net/test_listenbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from supysonic.listenbrainz import ListenBrainz

from ..frontend.frontendtestbase import FrontendTestBase

class ListenBrainzTestCase(unittest.TestCase):
"""Basic test of unauthenticated ListenBrainz API method"""

Expand All @@ -22,5 +24,18 @@ def test_request(self):
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()

0 comments on commit 1cfca94

Please sign in to comment.