Source code for intranet.apps.parking.tests
from django.conf import settings
from django.contrib.auth import get_user_model
from django.urls import reverse
from ...test.ion_test import IonTestCase
from .models import CarApplication, ParkingApplication
[docs]class ParkingTest(IonTestCase):
"""Tests for the parking module."""
[docs] def login_with_args(self, uname, grad_year):
user = get_user_model().objects.get_or_create(username=uname, graduation_year=grad_year)[0]
with self.settings(MASTER_PASSWORD="pbkdf2_sha256$24000$qp64pooaIEAc$j5wiTlyYzcMu08dVaMRus8Kyfvn5ZfaJ/Rn+Z/fH2Bw="):
self.client.login(username=uname, password="dankmemes")
return user
[docs] def test_invalid_user(self):
user = self.login_with_args("bwilliam", settings.SENIOR_GRADUATION_YEAR + 2)
response = self.client.post(reverse("parking_form"), data={"email": user.tj_email, "mentorship": False})
# Check that parking application was not created
self.assertEqual(response.status_code, 302)
self.assertFalse(ParkingApplication.objects.filter(user=user).exists())
response = self.client.post(reverse("parking_car"), data={"license_plate": "TJCSL", "make": "Lamborghini", "model": "Veneno", "year": "2018"})
# Check that car application is not created
self.assertEqual(response.status_code, 302)
self.assertFalse(ParkingApplication.objects.filter(user=user).exists())