Files
Example-TCG-Site/users/tests/test_general.py
Ryan Westfall 739d136209 Last bit of major changes
Closes #1
Closes #5
Closes #6
Closes #8
Closes #9
Closes #10
2026-01-26 04:11:38 -06:00

31 lines
1.0 KiB
Python

from django.test import TestCase
from django.urls import reverse
from .models import User
class ProfileThemeTest(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='testuser', password='password')
self.client.login(username='testuser', password='password')
def test_theme_preference_update(self):
# Default should be dark
self.assertEqual(self.user.profile.theme_preference, 'dark')
# Check if form is in context
response = self.client.get(reverse('users:profile'))
self.assertEqual(response.status_code, 200)
self.assertIn('form', response.context)
# Update theme to light
response = self.client.post(reverse('users:profile'), {
'theme_preference': 'light'
})
# Should redirect back to profile
self.assertRedirects(response, reverse('users:profile'))
# Check if updated in DB
self.user.profile.refresh_from_db()
self.assertEqual(self.user.profile.theme_preference, 'light')