test_playlists.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from unittest import skip
  2. from uuid import UUID
  3. from . import BaseAPITestCase
  4. from furl import furl
  5. from rest_framework import status
  6. from rest_framework.reverse import reverse as drf_reverse
  7. class PlaylistTests(BaseAPITestCase):
  8. def setUp(self):
  9. self.playlist_name = "Ishaan"
  10. self.playlist_uuid = UUID("e6b8e65c-f325-4764-9a8a-7ec2c40af125")
  11. def test_list_playlists(self):
  12. # the total count of playlist is 1
  13. url = drf_reverse("playlist-list", kwargs={"version": self.version})
  14. r = self.client.get(url)
  15. self.assertEqual(r.status_code, status.HTTP_200_OK)
  16. self.assertEqual(r.data["count"], 1)
  17. def test_search_playlists(self):
  18. # Should be able to search for playlists by `name`.
  19. url = drf_reverse("playlist-list", kwargs={"version": self.version})
  20. url = furl(url).set({"name": self.playlist_name}).url
  21. r = self.client.get(url)
  22. self.assertEqual(r.status_code, status.HTTP_200_OK)
  23. self.assertEqual(r.data["count"], 1)
  24. self.assertEqual(r.data["results"][0]["uuid"], self.playlist_uuid)
  25. def test_get_playlist(self):
  26. # Should be able to fetch a playlist by its `uuid`.
  27. url = drf_reverse(
  28. "playlist-detail", kwargs={"version": self.version, "uuid": self.playlist_uuid}
  29. )
  30. r = self.client.get(url)
  31. self.assertEqual(r.status_code, status.HTTP_200_OK)
  32. self.assertEqual(r.data["name"], self.playlist_name)
  33. @skip
  34. def test_create_playlist(self):
  35. # Should be able to create a playlist with 0 or more tracks.
  36. raise NotImplementedError("This test case needs to be implemented.")
  37. @skip
  38. def test_update_playlist(self):
  39. # Should be able to change a playlist's `name`, and add, remove,
  40. # or re-order tracks.
  41. raise NotImplementedError("This test case needs to be implemented.")
  42. @skip
  43. def test_delete_playlist(self):
  44. # Should be able to delete a playlist by `uuid`.
  45. raise NotImplementedError("This test case needs to be implemented.")