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 ChangePasswordTest(TestCase): def setUp(self): self.client = Client() self.url = "/api/accounts/change_password" self.username: str = str(uuid.uuid4()) self.password: str = str(uuid.uuid4()) self.new_password: str = str(uuid.uuid4()) User.objects.create_user(username = self.username, password = self.password) def test_normal(self): self.client.login(username = self.username, password = self.password) response: HttpResponse = self.client.post(self.url, {"new_password": self.new_password}) response_text: str = response.content.decode('utf-8') self.assertEqual(response_text, USER_PASSWORD_UPDATED) def test_nologged(self): response: HttpResponse = self.client.post(self.url, {"new_password": self.new_password}) response_text: str = response.content.decode('utf-8') self.assertEqual(response_text, '')