from django.test import TestCase

# Create your tests here.
class BasicTestCase(TestCase):
    """Test getting various urls for user app"""
    def test_getting_login(self):
        self.client.get('/user/login')

    def test_getting_register(self):
        self.client.get('/user/register')

    def test_getting_(self):
        self.client.get('/alerts')

from django.test import TestCase

from django.contrib.auth import get_user_model
User = get_user_model()

# Create your tests here.
class TestUserFunction(TestCase):
    """Test getting various urls for user app"""
    def setUp(self):
        self.test_user = create_user()

    def test_getting_login(self):
        self.assertEqual(self.client.get('/user/login/').status_code, 200)

    def test_getting_register(self):
        self.assertEqual(self.client.get('/user/register/').status_code, 200)

    def test_login(self):
        self.assertFalse(self.client.login(username="test_user", password="wrong_password"))
        self.assertFalse(self.client.login(username="nonexistant_user", password="password"))
        self.assertTrue(self.client.login(username="test_user", password="password"))

def create_user():
    return User.objects.create_user("test_user", email="user@bikemaps.org", password="password")

def create_superuser():
    return User.objects.create_superuser("test_superuser", email="super_user@bikemaps.org", password="password")

Add more thorough testing to user app
Add more thorough testing to user app

  from django.test import TestCase
  
+ from django.contrib.auth import get_user_model
+ User = get_user_model()
+ 
  # Create your tests here.
- class BasicTestCase(TestCase):
+ class TestUserFunction(TestCase):
      """Test getting various urls for user app"""
+     def setUp(self):
+         self.test_user = create_user()
+ 
      def test_getting_login(self):
-         self.client.get('/user/login')
+         self.assertEqual(self.client.get('/user/login/').status_code, 200)
  
      def test_getting_register(self):
-         self.client.get('/user/register')
+         self.assertEqual(self.client.get('/user/register/').status_code, 200)
  
-     def test_getting_(self):
+     def test_login(self):
-         self.client.get('/alerts')
+         self.assertFalse(self.client.login(username="test_user", password="wrong_password"))
+         self.assertFalse(self.client.login(username="nonexistant_user", password="password"))
+         self.assertTrue(self.client.login(username="test_user", password="password"))
  
+ def create_user():
+     return User.objects.create_user("test_user", email="user@bikemaps.org", password="password")
+ 
+ def create_superuser():
+     return User.objects.create_superuser("test_superuser", email="super_user@bikemaps.org", password="password")
+ 
Add more thorough testing to user app
## Code Before:
from django.test import TestCase

# Create your tests here.
class BasicTestCase(TestCase):
    """Test getting various urls for user app"""
    def test_getting_login(self):
        self.client.get('/user/login')

    def test_getting_register(self):
        self.client.get('/user/register')

    def test_getting_(self):
        self.client.get('/alerts')

## Instruction:
Add more thorough testing to user app
## Code After:
from django.test import TestCase

from django.contrib.auth import get_user_model
User = get_user_model()

# Create your tests here.
class TestUserFunction(TestCase):
    """Test getting various urls for user app"""
    def setUp(self):
        self.test_user = create_user()

    def test_getting_login(self):
        self.assertEqual(self.client.get('/user/login/').status_code, 200)

    def test_getting_register(self):
        self.assertEqual(self.client.get('/user/register/').status_code, 200)

    def test_login(self):
        self.assertFalse(self.client.login(username="test_user", password="wrong_password"))
        self.assertFalse(self.client.login(username="nonexistant_user", password="password"))
        self.assertTrue(self.client.login(username="test_user", password="password"))

def create_user():
    return User.objects.create_user("test_user", email="user@bikemaps.org", password="password")

def create_superuser():
    return User.objects.create_superuser("test_superuser", email="super_user@bikemaps.org", password="password")
