From 2025d26a5c5ccd64a53b1e63f0081bdb6f38115c Mon Sep 17 00:00:00 2001 From: Kyattsukuro Date: Thu, 18 Sep 2025 11:17:46 +0200 Subject: [PATCH] fixed tests --- README.md | 3 +++ simple_chat_api/tests/auth_entpoints.py | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8802aa7..bbc0e2a 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,6 @@ For the backend, install dependencies and run the server: pip install -r simple_chat_api/requirements.txt DEV=true python -m simple_chat_api ``` + +To run tests: +`python -m unittest discover -s simple_chat_api/tests -p "*.py"` diff --git a/simple_chat_api/tests/auth_entpoints.py b/simple_chat_api/tests/auth_entpoints.py index 5184ac4..8585241 100644 --- a/simple_chat_api/tests/auth_entpoints.py +++ b/simple_chat_api/tests/auth_entpoints.py @@ -185,10 +185,19 @@ class TestAuthEndpoints(unittest.TestCase): for user,session in self.userSessions.items(): with self.subTest(user=user): pyload = { - "new_password": "newadminpass" + "old_password": users[user], + "new_password": "newpass" } - response = session.post(f"{API_URL}/user/changePassword/", json=pyload) - self.assertEqual(response.status_code, 200, f"Admin failed to change password; {response.text}") + response = session.post(f"{API_URL}/user/changePassword", json=pyload) + self.assertEqual(response.status_code, 200, f"Failed to change password; {response.text}") + + pyload = { + "new_password": users[user], + "old_password": "newpass" + } + response = session.post(f"{API_URL}/user/changePassword", json=pyload) + self.assertEqual(response.status_code, 200, f"Failed to change passwords back; {response.text}") + class TestMessage(unittest.TestCase):