Created
          September 19, 2018 12:32 
        
      - 
      
 - 
        
Save charisschomba/a71447f8a75e557e921d4afb4dd802a7 to your computer and use it in GitHub Desktop.  
    Testing if the user can login successfully 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 | 
Very straight to the point test.
Work on the comments and doc strings.
Here is a resource on pep8 docstring standard.
https://www.python.org/dev/peps/pep-0257/
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
  
            
The test is ok. But you should be commenting your code, or you can add doc strings to your functions and classes.