# Path: securedpi_locks/models.py
# class Lock(models.Model):
#     """Define class for user profile."""
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL,
#         related_name='locks',
#         on_delete=models.CASCADE
#     )
#     name = models.CharField(max_length=20)
#     location = models.CharField(max_length=50)
#     description = models.CharField(max_length=50, blank=True)
#     date_created = models.DateField(auto_now_add=True)
#     date_modified = models.DateField(auto_now=True)
#     serial = models.CharField(max_length=50, unique=True)
#     status = models.CharField(max_length=20, default='unlocked')
#     is_active = models.BooleanField(default=False)
#     facial_recognition = models.BooleanField(default=False)
#     RFID = models.CharField(max_length=100, blank=True)
# 
#     def __str__(self):
#         return 'Lock for {}'.format(self.user)


from django.test import TestCase
from django.urls import reverse
from django.core import mail
from django.contrib.auth.models import User
from securedpi_locks.models import Lock
    def test_redirected_to_dashboard_after_logged_in(self):
        """Prove redirection to the home page after loggin in."""
        self.assertEqual(self.login_response.url, self.dashboard_url)

    def test_not_redirected_when_failed_login(self):
        """Prove that the user is not redirected if wrong credentials."""
        self.assertEqual(self.bad_login_response.status_code, 200)

    def test_logout_succesful_redirection(self):
        """Test successful logout redirection."""
        self.assertEqual(self.logout_response.status_code, 302)

    def test_redirected_to_dashboard_after_logged_out(self):
        """Prove redirection to the home page after loggin out."""
        self.assertEqual(self.logout_response.url, self.dashboard_url)


class DashboardViewTestCase(TestCase):
    """Define test class for Dashboard view."""
    def setUp(self):
        """Define setup for tests."""
        self.user = User(username='test')
        self.user.save()
        self.client.force_login(user=self.user)
        self.lock1 = Lock(
            user=self.user,
            name='lock1',
            location='codefellows',
            serial='pi12345')
        self.lock1.save()

# Path: securedpi_locks/models.py
# class Lock(models.Model):
#     """Define class for user profile."""
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL,
#         related_name='locks',
#         on_delete=models.CASCADE
#     )
#     name = models.CharField(max_length=20)
#     location = models.CharField(max_length=50)
#     description = models.CharField(max_length=50, blank=True)
#     date_created = models.DateField(auto_now_add=True)
#     date_modified = models.DateField(auto_now=True)
#     serial = models.CharField(max_length=50, unique=True)
#     status = models.CharField(max_length=20, default='unlocked')
#     is_active = models.BooleanField(default=False)
#     facial_recognition = models.BooleanField(default=False)
#     RFID = models.CharField(max_length=100, blank=True)
# 
#     def __str__(self):
#         return 'Lock for {}'.format(self.user)


# Path: securedpi/test.py
from django.test import TestCase
from django.urls import reverse
from django.core import mail
from django.contrib.auth.models import User
from securedpi_locks.models import Lock

    def test_redirected_to_dashboard_after_logged_in(self):
        """Prove redirection to the home page after loggin in."""
        self.assertEqual(self.login_response.url, self.dashboard_url)

    def test_not_redirected_when_failed_login(self):
        """Prove that the user is not redirected if wrong credentials."""
        self.assertEqual(self.bad_login_response.status_code, 200)

    def test_logout_succesful_redirection(self):
        """Test successful logout redirection."""
        self.assertEqual(self.logout_response.status_code, 302)

    def test_redirected_to_dashboard_after_logged_out(self):
        """Prove redirection to the home page after loggin out."""
        self.assertEqual(self.logout_response.url, self.dashboard_url)


class DashboardViewTestCase(TestCase):
    """Define test class for Dashboard view."""
    def setUp(self):
        """Define setup for tests."""
        self.user = User(username='test')
        self.user.save()
        self.client.force_login(user=self.user)
        self.lock1 = Lock(
            user=self.user,
            name='lock1',
            location='codefellows',
            serial='pi12345')
        self.lock1.save()

        self.lock2 = Lock(