34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
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
|
|
|
|
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())
|
|
|
|
user: User = User.objects.create_user(username=self.username, password=self.password)
|
|
self.client.login(username=self.username, password=self.password)
|
|
|
|
|
|
def test_normal_delete(self):
|
|
response: HttpResponse = self.client.post(self.url)
|
|
response_text: str = response.content.decode("utf-8")
|
|
self.assertEqual(response_text, USER_DELETED)
|
|
|
|
def test_no_logged(self):
|
|
self.client.logout()
|
|
response: HttpResponse = self.client.post(self.url)
|
|
response_text: str = response.content.decode("utf-8")
|
|
self.assertEqual(response_text, '') |