mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 01:58:54 +02:00
Add tests
This commit is contained in:
29
app/apps/users/tests.py
Normal file
29
app/apps/users/tests.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.test import TestCase, Client
|
||||
from django.contrib.auth.models import User
|
||||
from django.urls import reverse
|
||||
|
||||
class UsersTestCase(TestCase):
|
||||
def test_example(self):
|
||||
self.assertEqual(1 + 1, 2)
|
||||
|
||||
def test_users_index_view_superuser(self):
|
||||
# Create a superuser
|
||||
superuser = User.objects.create_user(
|
||||
username='superuser',
|
||||
password='superpassword',
|
||||
is_staff=True,
|
||||
is_superuser=True
|
||||
)
|
||||
|
||||
# Create a Client instance
|
||||
client = Client()
|
||||
|
||||
# Log in the superuser
|
||||
client.login(username='superuser', password='superpassword')
|
||||
|
||||
# Make a GET request to the users_index view
|
||||
# Assuming your users_index view is named 'users_index' in the 'users' app namespace
|
||||
response = client.get(reverse('users:users_index'))
|
||||
|
||||
# Assert that the response status code is 200
|
||||
self.assertEqual(response.status_code, 200)
|
||||
Reference in New Issue
Block a user