Coverage for timelaps/tests.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
# Create your tests here.
# tests for views class BaseViewTest(APITestCase): client = APIClient()
@staticmethod def create_song(title="", artist=""): if title != "" and artist != "": Songs.objects.create(title=title, artist=artist)
def setUp(self): # add test data self.create_song("like glue", "sean paul") self.create_song("simple song", "konshens") self.create_song("love is wicked", "brick and lace") self.create_song("jam rock", "damien marley")
class GetAllSongsTest(BaseViewTest):
def test_get_all_songs(self):
#This test ensures that all songs added in the setUp method #exist when we make a GET request to the songs/ endpoint
# hit the API endpoint response = self.client.get( reverse("songs-all", kwargs={"version": "v1"}) ) # fetch the data from db expected = Songs.objects.all() serialized = SongsSerializer(expected, many=True) self.assertEqual(response.data, serialized.data) self.assertEqual(response.status_code, status.HTTP_200_OK)
""" |