ft_transcendence/profiles/tests.py

17 lines
677 B
Python
Raw Normal View History

2023-10-24 12:28:42 -04:00
from django.test import TestCase
2023-10-29 16:09:38 -04:00
from django.http import HttpResponse, HttpRequest
from django.contrib.auth.models import User
2023-10-24 12:28:42 -04:00
# Create your tests here.
2023-10-29 16:09:38 -04:00
class ProfileTest(TestCase):
def setUp(self):
self.user: User = User.objects.create(username='bozo', password='password')
self.user.save()
self.expected_response = {"username": "bozo",
"title": ""}
def test_profile_create_on_user_created(self):
response: HttpResponse = self.client.get(f"/api/profiles/{self.user.pk}")
response_dict: dict = eval(response.content)
self.assertEqual(self.expected_response, response_dict)