Skip to content

Instantly share code, notes, and snippets.

@charisschomba
Created September 19, 2018 12:32
Show Gist options
  • Save charisschomba/a71447f8a75e557e921d4afb4dd802a7 to your computer and use it in GitHub Desktop.
Save charisschomba/a71447f8a75e557e921d4afb4dd802a7 to your computer and use it in GitHub Desktop.
Testing if the user can login successfully
from django.test import TestCase
from rest_framework import status
from rest_framework.test import APIClient
class LoginTestCase(TestCase):
def setUp():
self.client = APIClient()
self.user = {
"username": "andela",
"password": "andela2018"
}
def test_successful_login(self):
response = self.client.post("/api/users/", self.user, format="json")
self.assertEqual(response.response_code, status.HTTP_200_OK)
def tearDown(self):
pass
@bevkololi
Copy link

These two took the words right out of my mouth. Good job though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment