58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
from django.contrib.auth import get_user_model
|
|
from django.test import Client, TestCase
|
|
|
|
from workflows.models import UserProfile
|
|
|
|
|
|
class AccountUISmokeTests(TestCase):
|
|
def setUp(self):
|
|
self.user = get_user_model().objects.create_user(
|
|
username='profile-user',
|
|
email='profile@example.com',
|
|
password='secret-12345',
|
|
first_name='Profile',
|
|
last_name='User',
|
|
)
|
|
self.client = Client()
|
|
self.client.force_login(self.user)
|
|
|
|
def test_account_profile_page_renders(self):
|
|
response = self.client.get('/account/', HTTP_HOST='localhost')
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertContains(response, 'profile@example.com')
|
|
self.assertContains(response, 'Passwort ändern')
|
|
|
|
def test_password_change_page_renders(self):
|
|
response = self.client.get('/accounts/password_change/', HTTP_HOST='localhost')
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertContains(response, 'Aktuelles Passwort')
|
|
|
|
def test_user_profile_is_created_automatically(self):
|
|
self.assertTrue(UserProfile.objects.filter(user=self.user).exists())
|
|
|
|
def test_account_profile_details_can_be_updated(self):
|
|
response = self.client.post(
|
|
'/account/',
|
|
{
|
|
'account_form': 'details',
|
|
'first_name': 'Updated',
|
|
'last_name': 'User',
|
|
'email': 'updated@example.com',
|
|
'phone_number': '030 123456',
|
|
'mobile_number': '0176 123456',
|
|
'job_title': 'IT Manager',
|
|
'department': 'IT',
|
|
'location': 'Berlin',
|
|
'contact_notes': 'Available in the mornings',
|
|
},
|
|
HTTP_HOST='localhost',
|
|
follow=True,
|
|
)
|
|
self.assertEqual(response.status_code, 200)
|
|
self.user.refresh_from_db()
|
|
profile = self.user.profile
|
|
self.assertEqual(self.user.first_name, 'Updated')
|
|
self.assertEqual(self.user.email, 'updated@example.com')
|
|
self.assertEqual(profile.phone_number, '030 123456')
|
|
self.assertEqual(profile.job_title, 'IT Manager')
|