From 0a5f51a4055bb496006b85859c40114d81afabb0 Mon Sep 17 00:00:00 2001 From: EmilOrv Date: Tue, 1 Apr 2025 17:16:33 +0200 Subject: [PATCH] initialize test cases --- .../tests/{TestUser.py => TestPassword.py} | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) rename backend/tests/{TestUser.py => TestPassword.py} (55%) diff --git a/backend/tests/TestUser.py b/backend/tests/TestPassword.py similarity index 55% rename from backend/tests/TestUser.py rename to backend/tests/TestPassword.py index a1b903c..b967db4 100644 --- a/backend/tests/TestUser.py +++ b/backend/tests/TestPassword.py @@ -7,13 +7,13 @@ from django.test import TestCase @pytest.mark.django_db -class TestUser(TestCase): +class TestPassword(TestCase): def setUp(self): self.client = APIClient() self.user = get_user_model().objects.create_user(username="testuser", password="password") self.client.force_authenticate(self.user) - def test_create_workout_valid(self): # + def test_signup_valid_password(self): # response = self.client.post("/api/workouts/", { "name": "Morning Run", "date": now().isoformat(), @@ -27,7 +27,31 @@ def test_create_workout_valid(self): # assert response.status_code == 201 assert Workout.objects.count() == 1 - def test_create_workout_invalid_date(self): # + def test_signup_short_password(self): # + response = self.client.post("/api/workouts/", { + "name": "Invalid Run", + "date": "invalid_date", + "notes": "Wrong format", + "visibility": "PU", # Adding required field + "owner": self.user.id, # Adding required field + "exercise_instances": [] # Adding required field + }, format="json") + + assert response.status_code == 400 # Should return validation error + + def test_signup_simple_password(self): # + response = self.client.post("/api/workouts/", { + "name": "Invalid Run", + "date": "invalid_date", + "notes": "Wrong format", + "visibility": "PU", # Adding required field + "owner": self.user.id, # Adding required field + "exercise_instances": [] # Adding required field + }, format="json") + + assert response.status_code == 400 # Should return validation error + + def test_signup_only_numeric_password(self): response = self.client.post("/api/workouts/", { "name": "Invalid Run", "date": "invalid_date",