Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ...
- # Add this line at the top of the tests.py file
- from django.contrib.auth.models import User
- # update the BaseViewTest to this
- class BaseViewTest(APITestCase):
- client = APIClient()
- @staticmethod
- def create_song(title="", artist=""):
- if title != "" and artist != "":
- Songs.objects.create(title=title, artist=artist)
- def login_a_user(self, username="", password=""):
- url = reverse(
- "auth-login",
- kwargs={
- "version": "v1"
- }
- )
- return self.client.post(
- url,
- data=json.dumps({
- "username": username,
- "password": password
- }),
- content_type="application/json"
- )
- def setUp(self):
- # create a admin user
- self.user = User.objects.create_superuser(
- username="test_user",
- email="test@mail.com",
- password="testing",
- first_name="test",
- last_name="user",
- )
- # 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")
Add Comment
Please, Sign In to add comment