ft_transcendence/accounts/tests/delete.py

34 lines
1.0 KiB
Python
Raw Normal View History

2023-10-25 10:17:55 -04:00
from django.test import TestCase
# Create your tests here.
from django.test.client import Client
from django.http import HttpResponse
from django.contrib.auth.models import User
2023-10-25 10:17:55 -04:00
import uuid
from ..status_code import *
class DeleteTest(TestCase):
def setUp(self):
self.client = Client()
self.url = "/api/accounts/delete"
self.username: str = str(uuid.uuid4())
self.password: str = str(uuid.uuid4())
2023-10-25 10:17:55 -04:00
user: User = User.objects.create_user(username=self.username, password=self.password)
self.client.login(username=self.username, password=self.password)
2023-10-25 10:17:55 -04:00
def test_normal_delete(self):
response: HttpResponse = self.client.post(self.url)
2023-10-25 10:17:55 -04:00
response_text: str = response.content.decode("utf-8")
self.assertEqual(response_text, USER_DELETED)
2023-10-25 10:17:55 -04:00
def test_no_logged(self):
self.client.logout()
response: HttpResponse = self.client.post(self.url)
2023-10-25 10:17:55 -04:00
response_text: str = response.content.decode("utf-8")
self.assertEqual(response_text, '')