Hide keyboard shortcuts

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

# -*- coding: utf-8 -*- 

from __future__ import unicode_literals 

 

from django.test import TestCase 

 

# Create your tests here. 

from django.urls import reverse 

from rest_framework.test import APITestCase, APIClient 

from rest_framework.views import status 

from .models import * 

from .serializers import DriverSerializer 

 

""" 

# 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) 

 

"""