diff --git a/accounts/tests/delete.py b/accounts/tests/delete.py index 7ef6c3a..950ac04 100644 --- a/accounts/tests/delete.py +++ b/accounts/tests/delete.py @@ -11,7 +11,7 @@ class DeleteTest(TestCase): def setUp(self): self.client = Client() - self.url = "/accounts/delete" + self.url = "/api/accounts/delete" self.username: str = str(uuid.uuid4()) self.password: str = str(uuid.uuid4()) diff --git a/accounts/tests/edit.py b/accounts/tests/edit.py new file mode 100644 index 0000000..4d79787 --- /dev/null +++ b/accounts/tests/edit.py @@ -0,0 +1,31 @@ +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 + +class ChangePasswordTest(TestCase): + def setUp(self): + self.client = Client() + + self.url = "/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, {"current_password": self.password, "new_password": self.new_password}) + response_text: str = response.content.decode('utf-8') + self.assertEqual(response_text, '"password changed"') + + def test_nologged(self): + response: HttpResponse = self.client.post(self.url, {"current_password": self.password, "new_password": self.new_password}) + errors: dict = eval(response.content) + self.assertDictEqual(errors, {'detail': 'Authentication credentials were not provided.'}) \ No newline at end of file diff --git a/accounts/tests/login.py b/accounts/tests/login.py index 2d1190a..46d41ab 100644 --- a/accounts/tests/login.py +++ b/accounts/tests/login.py @@ -10,7 +10,7 @@ class LoginTest(TestCase): def setUp(self): self.client = Client() - self.url = "/accounts/login" + self.url = "/api/accounts/login" self.username: str = str(uuid.uuid4()) self.password: str = str(uuid.uuid4()) diff --git a/accounts/tests/logout.py b/accounts/tests/logout.py index d0f5f80..699d27e 100644 --- a/accounts/tests/logout.py +++ b/accounts/tests/logout.py @@ -8,7 +8,7 @@ class LoginTest(TestCase): def setUp(self): self.client = Client() - self.url = "/accounts/logout" + self.url = "/api/accounts/logout" self.client.login() diff --git a/accounts/tests/register.py b/accounts/tests/register.py index 21dc0f0..5500ada 100644 --- a/accounts/tests/register.py +++ b/accounts/tests/register.py @@ -11,7 +11,7 @@ class RegisterTest(TestCase): def setUp(self): self.client = Client() - self.url: str = "/accounts/register" + self.url: str = "/api/accounts/register" self.username: str = str(uuid.uuid4()) self.password: str = str(uuid.uuid4())