mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2024-11-26 22:07:09 +00:00
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
|
# -*- mode: python; coding: utf-8 -*-
|
||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
|
from django.core import mail
|
||
|
from django.test import TestCase
|
||
|
from django.urls import reverse
|
||
|
from users.models import User
|
||
|
|
||
|
"""
|
||
|
Test that every page render
|
||
|
"""
|
||
|
|
||
|
|
||
|
class TemplateTests(TestCase):
|
||
|
def setUp(self):
|
||
|
self.user = User.objects.create_superuser(
|
||
|
username="admin",
|
||
|
password="adminadmin",
|
||
|
email="admin@example.com",
|
||
|
)
|
||
|
self.client.force_login(self.user)
|
||
|
|
||
|
def test_users_edit_info(self):
|
||
|
response = self.client.get(reverse('users:edit-info'))
|
||
|
self.assertEqual(response.status_code, 200)
|
||
|
|
||
|
def test_users_user_changelist(self):
|
||
|
response = self.client.get(reverse('admin:users_user_changelist'))
|
||
|
self.assertEqual(response.status_code, 200)
|
||
|
|
||
|
def test_users_user_creation_form(self):
|
||
|
response = self.client.get(reverse('admin:users_user_add'))
|
||
|
self.assertEqual(response.status_code, 200)
|
||
|
|
||
|
def test_users_user_add_init_mail(self):
|
||
|
"""
|
||
|
Test that an initialization mail is send when a new user is added
|
||
|
"""
|
||
|
data = {
|
||
|
'username': "test_user",
|
||
|
'email': "test@example.com",
|
||
|
'first_name': "Test",
|
||
|
'last_name': "User",
|
||
|
}
|
||
|
response = self.client.post(reverse(
|
||
|
'admin:users_user_add',
|
||
|
), data=data)
|
||
|
self.assertEqual(len(mail.outbox), 1)
|
||
|
self.assertEqual(response.status_code, 302)
|