diff --git a/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_Image.py b/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_Image.py index 2ad26913981aab903a4fd893224e4465577e9e86..24f3b3b24148a1d21b58c207045cf1eb23ed76cd 100644 --- a/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_Image.py +++ b/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_Image.py @@ -4,9 +4,9 @@ This file tests the accuracy of the misplaced item detection algorithm by uploading images containing various items and verifying if the system correctly identifies items that are misplaced according to predefined rules. It includes three tests: -1. Verifying that a remote is detected as misplaced in the image 'test1.jpg'. -2. Verifying that a handbag is detected as misplaced in the image 'test2.jpg'. -3. Verifying that no items are detected as misplaced in the image 'test3.jpg'. +Test ID-> MI1: Verify that a remote is detected as misplaced in the image 'test1.jpg'. +Test ID-> MI2: Verify that a handbag is detected as misplaced in the image 'test2.jpg'. +Test ID-> MI3: Verify that no items are detected as misplaced in the image 'test3.jpg'. Additionally, it ensures that the uploaded images are deleted after the tests. """ @@ -78,7 +78,7 @@ class TestAlgorithmAccuracy(APITestCase): def test_remote_misplaced_detection(self): """ - Test that the remote is detected as misplaced in the uploaded image 'test1.jpg'. + Test ID-> MI1: Verify that a remote is detected as misplaced in the image 'test1.jpg'. """ test_image_path = self.test_image_paths['test1.jpg'] @@ -122,7 +122,7 @@ class TestAlgorithmAccuracy(APITestCase): def test_handbag_misplaced_detection(self): """ - Test that the handbag is detected as misplaced in the uploaded image 'test2.jpg'. + Test ID-> MI2: Verify that a handbag is detected as misplaced in the image 'test2.jpg'. """ test_image_path = self.test_image_paths['test2.jpg'] @@ -166,7 +166,7 @@ class TestAlgorithmAccuracy(APITestCase): def test_no_misplaced_items_detection(self): """ - Test that no items are detected as misplaced in the uploaded image 'test3.jpg'. + Test ID-> MI3: Verify that no items are detected as misplaced in the image 'test3.jpg'. """ test_image_path = self.test_image_paths['test3.jpg'] diff --git a/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_video.py b/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_video.py index 7fa3432761b63397fc6ec2c9a6ec86c3d0fde842..044b3edf1e0e18c039b304a7295bd514f870caf1 100644 --- a/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_video.py +++ b/MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_video.py @@ -1,20 +1,20 @@ -#MisplaceAI\process_misplaced_manager\tests\misplacedTestAlgorithm\test_Misplaced_Items_video.py +# MisplaceAI/process_misplaced_manager/tests/misplacedTestAlgorithm/test_Misplaced_Items_video.py """ This file contains tests for video detection functionality in the MisplaceAI application. It includes tests to: -1. Verify that a specific item ('potted plant') is detected as misplaced in an uploaded video. -2. Ensure that the uploaded video can be deleted successfully. -3. Check that the length of the processed video is as expected (30 seconds). +Test ID-> MV1: Verify that a specific item ('potted plant') is detected as misplaced in an uploaded video. +Test ID-> MV2: Ensure that the uploaded video can be deleted successfully. +Test ID-> MV3: Check that the length of the processed video is as expected (30 seconds). """ -import os # Importing the os module for interacting with the operating system -from django.urls import reverse # Importing reverse to generate URL for a given view -from rest_framework import status # Importing status to use HTTP status codes -from rest_framework.test import APITestCase # Importing APITestCase to create API test cases -from django.contrib.auth.models import User # Importing User model to create test users -from process_misplaced_manager.models import DetectionLimitSetting, DailyDetectionLimit # Importing models for setting detection limits -from moviepy.editor import VideoFileClip # Importing VideoFileClip to handle video files +import os +from django.urls import reverse +from rest_framework import status +from rest_framework.test import APITestCase +from django.contrib.auth.models import User +from process_misplaced_manager.models import DetectionLimitSetting, DailyDetectionLimit +from moviepy.editor import VideoFileClip class TestVideoAlgorithmAccuracy(APITestCase): def setUp(self): @@ -59,7 +59,7 @@ class TestVideoAlgorithmAccuracy(APITestCase): def test_potted_plant_misplaced_detection(self): """ - Test that the potted plant is detected as misplaced in the uploaded video. + Test ID-> MV1: Verify that a specific item ('potted plant') is detected as misplaced in an uploaded video. """ # Get the path to the test video test_video_path = self.test_video_path @@ -103,7 +103,7 @@ class TestVideoAlgorithmAccuracy(APITestCase): def test_video_deletion(self): """ - Test that the uploaded video is deleted successfully. + Test ID-> MV2: Ensure that the uploaded video can be deleted successfully. """ # Get the path to the test video test_video_path = self.test_video_path @@ -142,7 +142,7 @@ class TestVideoAlgorithmAccuracy(APITestCase): def test_processed_video_length(self): """ - Test that the length of the processed video is as expected. + Test ID-> MV3: Check that the length of the processed video is as expected (30 seconds). """ # Get the path to the test video test_video_path = self.test_video_path diff --git a/MisplaceAI/rules/tests/test_items.py b/MisplaceAI/rules/tests/test_items.py index 080f8b3a994b3177c3df9f2c5f145ec8c0f66077..355903cdf92528484e9d0410905878036546095e 100644 --- a/MisplaceAI/rules/tests/test_items.py +++ b/MisplaceAI/rules/tests/test_items.py @@ -1,19 +1,19 @@ # misplaceAI/rules/tests/test_items.py """ -Test 1: test_create_item_as_admin - Test that an admin user can create a new item. -Test 2: test_create_item_as_normal_user - Test that a normal user cannot create a new item. -Test 3: test_delete_item_as_admin - Test that an admin user can delete an existing item. -Test 4: test_delete_item_as_normal_user - Test that a normal user cannot delete an existing item. -Test 5: test_get_items_as_normal_user - Test that a normal user can retrieve the list of items. -Test 6: test_update_item_as_admin - Test that an admin user can update an existing item. -Test 7: test_update_item_as_normal_user - Test that a normal user cannot update an existing item. -Test 8: test_create_item_with_invalid_data - Test that creating an item with invalid data returns validation errors. -Test 9: test_get_item_detail_as_admin - Test that an admin user can retrieve the details of a specific item. -Test 10: test_get_item_detail_as_normal_user - Test that a normal user can retrieve the details of a specific item. -Test 11: test_create_duplicate_item_as_admin - Test that creating a duplicate item as admin returns an error. -Test 12: test_partial_update_item_as_admin - Test that an admin user can perform partial updates on an item. -Test 13: test_unauthenticated_access - Test that unauthenticated users cannot access any item endpoints. +Test ID-> IT1: test_create_item_as_admin - Test that an admin user can create a new item. +Test ID-> IT2: test_create_item_as_normal_user - Test that a normal user cannot create a new item. +Test ID-> IT3: test_delete_item_as_admin - Test that an admin user can delete an existing item. +Test ID-> IT4: test_delete_item_as_normal_user - Test that a normal user cannot delete an existing item. +Test ID-> IT5: test_get_items_as_normal_user - Test that a normal user can retrieve the list of items. +Test ID-> IT6: test_update_item_as_admin - Test that an admin user can update an existing item. +Test ID-> IT7: test_update_item_as_normal_user - Test that a normal user cannot update an existing item. +Test ID-> IT8: test_create_item_with_invalid_data - Test that creating an item with invalid data returns validation errors. +Test ID-> IT9: test_get_item_detail_as_admin - Test that an admin user can retrieve the details of a specific item. +Test ID-> IT10: test_get_item_detail_as_normal_user - Test that a normal user can retrieve the details of a specific item. +Test ID-> IT11: test_create_duplicate_item_as_admin - Test that creating a duplicate item as admin returns an error. +Test ID-> IT12: test_partial_update_item_as_admin - Test that an admin user can perform partial updates on an item. +Test ID-> IT13: test_unauthenticated_access - Test that unauthenticated users cannot access any item endpoints. """ from rest_framework import status @@ -37,7 +37,7 @@ class AdminManageItemViewTest(APITestCase): def test_create_item_as_admin(self): """ - Test 1: test_create_item_as_admin - Test that an admin user can create a new item. + Test ID-> IT1: test_create_item_as_admin - Test that an admin user can create a new item. """ self.client.force_authenticate(user=self.admin_user) data = {'name': 'New Item'} @@ -46,7 +46,7 @@ class AdminManageItemViewTest(APITestCase): def test_create_item_as_normal_user(self): """ - Test 2: test_create_item_as_normal_user - Test that a normal user cannot create a new item. + Test ID-> IT2: test_create_item_as_normal_user - Test that a normal user cannot create a new item. """ self.client.force_authenticate(user=self.normal_user) data = {'name': 'New Item'} @@ -55,7 +55,7 @@ class AdminManageItemViewTest(APITestCase): def test_delete_item_as_admin(self): """ - Test 3: test_delete_item_as_admin - Test that an admin user can delete an existing item. + Test ID-> IT3: test_delete_item_as_admin - Test that an admin user can delete an existing item. """ self.client.force_authenticate(user=self.admin_user) response = self.client.delete(self.detail_url(self.item.id)) @@ -63,7 +63,7 @@ class AdminManageItemViewTest(APITestCase): def test_delete_item_as_normal_user(self): """ - Test 4: test_delete_item_as_normal_user - Test that a normal user cannot delete an existing item. + Test ID-> IT4: test_delete_item_as_normal_user - Test that a normal user cannot delete an existing item. """ self.client.force_authenticate(user=self.normal_user) response = self.client.delete(self.detail_url(self.item.id)) @@ -71,7 +71,7 @@ class AdminManageItemViewTest(APITestCase): def test_get_items_as_normal_user(self): """ - Test 5: test_get_items_as_normal_user - Test that a normal user can retrieve the list of items. + Test ID-> IT5: test_get_items_as_normal_user - Test that a normal user can retrieve the list of items. """ self.client.force_authenticate(user=self.normal_user) response = self.client.get(self.url) @@ -79,7 +79,7 @@ class AdminManageItemViewTest(APITestCase): def test_update_item_as_admin(self): """ - Test 6: test_update_item_as_admin - Test that an admin user can update an existing item. + Test ID-> IT6: test_update_item_as_admin - Test that an admin user can update an existing item. """ self.client.force_authenticate(user=self.admin_user) data = {'name': 'Updated Item'} @@ -88,7 +88,7 @@ class AdminManageItemViewTest(APITestCase): def test_update_item_as_normal_user(self): """ - Test 7: test_update_item_as_normal_user - Test that a normal user cannot update an existing item. + Test ID-> IT7: test_update_item_as_normal_user - Test that a normal user cannot update an existing item. """ self.client.force_authenticate(user=self.normal_user) data = {'name': 'Updated Item'} @@ -97,7 +97,7 @@ class AdminManageItemViewTest(APITestCase): def test_create_item_with_invalid_data(self): """ - Test 8: test_create_item_with_invalid_data - Test that creating an item with invalid data returns validation errors. + Test ID-> IT8: test_create_item_with_invalid_data - Test that creating an item with invalid data returns validation errors. """ self.client.force_authenticate(user=self.admin_user) data = {'name': ''} @@ -106,7 +106,7 @@ class AdminManageItemViewTest(APITestCase): def test_get_item_detail_as_admin(self): """ - Test 9: test_get_item_detail_as_admin - Test that an admin user can retrieve the details of a specific item. + Test ID-> IT9: test_get_item_detail_as_admin - Test that an admin user can retrieve the details of a specific item. """ self.client.force_authenticate(user=self.admin_user) response = self.client.get(self.detail_url(self.item.id)) @@ -114,7 +114,7 @@ class AdminManageItemViewTest(APITestCase): def test_get_item_detail_as_normal_user(self): """ - Test 10: test_get_item_detail_as_normal_user - Test that a normal user can retrieve the details of a specific item. + Test ID-> IT10: test_get_item_detail_as_normal_user - Test that a normal user can retrieve the details of a specific item. """ self.client.force_authenticate(user=self.normal_user) response = self.client.get(self.detail_url(self.item.id)) @@ -122,7 +122,7 @@ class AdminManageItemViewTest(APITestCase): def test_create_duplicate_item_as_admin(self): """ - Test 11: test_create_duplicate_item_as_admin - Test that creating a duplicate item as admin returns an error. + Test ID-> IT11: test_create_duplicate_item_as_admin - Test that creating a duplicate item as admin returns an error. """ self.client.force_authenticate(user=self.admin_user) data = {'name': 'Test Item'} @@ -131,7 +131,7 @@ class AdminManageItemViewTest(APITestCase): def test_partial_update_item_as_admin(self): """ - Test 12: test_partial_update_item_as_admin - Test that an admin user can perform partial updates on an item. + Test ID-> IT12: test_partial_update_item_as_admin - Test that an admin user can perform partial updates on an item. """ self.client.force_authenticate(user=self.admin_user) data = {'name': 'Partially Updated Item'} @@ -143,7 +143,7 @@ class AdminManageItemViewTest(APITestCase): def test_unauthenticated_access(self): """ - Test 13: test_unauthenticated_access - Test that unauthenticated users cannot access any item endpoints. + Test ID-> IT13: test_unauthenticated_access - Test that unauthenticated users cannot access any item endpoints. """ data = {'name': 'Unauthenticated Item'} response = self.client.post(self.url, data, format='json') diff --git a/MisplaceAI/rules/tests/test_locations.py b/MisplaceAI/rules/tests/test_locations.py index 32b210ea0a76fa643a3acd6f727b08ef2abff933..949464c1cbd4e5a92bb663015a6dc23b05621b7c 100644 --- a/MisplaceAI/rules/tests/test_locations.py +++ b/MisplaceAI/rules/tests/test_locations.py @@ -2,18 +2,18 @@ """ -Test 1: test_create_location_as_admin - Test that an admin user can create a new location. -Test 2: test_create_location_as_normal_user - Test that a normal user cannot create a new location. -Test 3: test_delete_location_as_admin - Test that an admin user can delete an existing location. -Test 4: test_delete_location_as_normal_user - Test that a normal user cannot delete an existing location. -Test 5: test_get_locations_as_normal_user - Test that a normal user can retrieve the list of locations. -Test 6: test_update_location_as_admin - Test that an admin user can update an existing location. -Test 7: test_update_location_as_normal_user - Test that a normal user cannot update an existing location. -Test 8: test_create_location_with_invalid_data - Test that creating a location with invalid data returns validation errors. -Test 9: test_get_location_detail_as_admin - Test that an admin user can retrieve the details of a specific location. -Test 10: test_get_location_detail_as_normal_user - Test that a normal user can retrieve the details of a specific location. -Test 11: test_partial_update_location_as_admin - Test that an admin user can perform partial updates on a location. -Test 12: test_partial_update_location_as_normal_user - Test that a normal user cannot perform partial updates on a location. +Test ID-> LT1: test_create_location_as_admin - Test that an admin user can create a new location. +Test ID-> LT2: test_create_location_as_normal_user - Test that a normal user cannot create a new location. +Test ID-> LT3: test_delete_location_as_admin - Test that an admin user can delete an existing location. +Test ID-> LT4: test_delete_location_as_normal_user - Test that a normal user cannot delete an existing location. +Test ID-> LT5: test_get_locations_as_normal_user - Test that a normal user can retrieve the list of locations. +Test ID-> LT6: test_update_location_as_admin - Test that an admin user can update an existing location. +Test ID-> LT7: test_update_location_as_normal_user - Test that a normal user cannot update an existing location. +Test ID-> LT8: test_create_location_with_invalid_data - Test that creating a location with invalid data returns validation errors. +Test ID-> LT9: test_get_location_detail_as_admin - Test that an admin user can retrieve the details of a specific location. +Test ID-> LT10: test_get_location_detail_as_normal_user - Test that a normal user can retrieve the details of a specific location. +Test ID-> LT11: test_partial_update_location_as_admin - Test that an admin user can perform partial updates on a location. +Test ID-> LT12: test_partial_update_location_as_normal_user - Test that a normal user cannot perform partial updates on a location. """ @@ -40,7 +40,7 @@ class AdminManageLocationViewTest(APITestCase): def test_create_location_as_admin(self): """ - Test 1: Ensure admin users can create a new location. + Test ID-> LT1: Ensure admin users can create a new location. """ self.client.force_authenticate(user=self.admin_user) data = {'name': 'New Location'} @@ -51,7 +51,7 @@ class AdminManageLocationViewTest(APITestCase): def test_create_location_as_normal_user(self): """ - Test 2: Ensure normal users cannot create a new location. + Test ID-> LT2: Ensure normal users cannot create a new location. """ self.client.force_authenticate(user=self.normal_user) data = {'name': 'New Location'} @@ -60,7 +60,7 @@ class AdminManageLocationViewTest(APITestCase): def test_delete_location_as_admin(self): """ - Test 3: Ensure admin users can delete an existing location. + Test ID-> LT3: Ensure admin users can delete an existing location. """ self.client.force_authenticate(user=self.admin_user) url = self.detail_url(self.location.id) @@ -70,7 +70,7 @@ class AdminManageLocationViewTest(APITestCase): def test_delete_location_as_normal_user(self): """ - Test 4: Ensure normal users cannot delete an existing location. + Test ID-> LT4: Ensure normal users cannot delete an existing location. """ self.client.force_authenticate(user=self.normal_user) url = self.detail_url(self.location.id) @@ -79,7 +79,7 @@ class AdminManageLocationViewTest(APITestCase): def test_get_locations_as_normal_user(self): """ - Test 5: Ensure normal users can retrieve the list of locations. + Test ID-> LT5: Ensure normal users can retrieve the list of locations. """ self.client.force_authenticate(user=self.normal_user) response = self.client.get(self.url) @@ -89,7 +89,7 @@ class AdminManageLocationViewTest(APITestCase): def test_update_location_as_admin(self): """ - Test 6: Ensure admin users can update an existing location. + Test ID-> LT6: Ensure admin users can update an existing location. """ self.client.force_authenticate(user=self.admin_user) url = self.detail_url(self.location.id) @@ -100,7 +100,7 @@ class AdminManageLocationViewTest(APITestCase): def test_update_location_as_normal_user(self): """ - Test 7: Ensure normal users cannot update an existing location. + Test ID-> LT7: Ensure normal users cannot update an existing location. """ self.client.force_authenticate(user=self.normal_user) url = self.detail_url(self.location.id) @@ -110,7 +110,7 @@ class AdminManageLocationViewTest(APITestCase): def test_create_location_with_invalid_data(self): """ - Test 8: Ensure creating a location with invalid data returns validation errors. + Test ID-> LT8: Ensure creating a location with invalid data returns validation errors. """ self.client.force_authenticate(user=self.admin_user) data = {'invalid_field': 'invalid_data'} @@ -119,7 +119,7 @@ class AdminManageLocationViewTest(APITestCase): def test_get_location_detail_as_admin(self): """ - Test 9: Ensure admin users can retrieve the details of a specific location. + Test ID-> LT9: Ensure admin users can retrieve the details of a specific location. """ self.client.force_authenticate(user=self.admin_user) url = self.detail_url(self.location.id) @@ -129,7 +129,7 @@ class AdminManageLocationViewTest(APITestCase): def test_get_location_detail_as_normal_user(self): """ - Test 10: Ensure normal users can retrieve the details of a specific location. + Test ID-> LT10: Ensure normal users can retrieve the details of a specific location. """ self.client.force_authenticate(user=self.normal_user) url = self.detail_url(self.location.id) @@ -139,7 +139,7 @@ class AdminManageLocationViewTest(APITestCase): def test_partial_update_location_as_admin(self): """ - Test 11: Ensure admin users can perform partial updates on a location. + Test ID-> LT11: Ensure admin users can perform partial updates on a location. """ self.client.force_authenticate(user=self.admin_user) url = self.detail_url(self.location.id) @@ -150,7 +150,7 @@ class AdminManageLocationViewTest(APITestCase): def test_partial_update_location_as_normal_user(self): """ - Test 12: Ensure normal users cannot perform partial updates on a location. + Test ID-> LT12: Ensure normal users cannot perform partial updates on a location. """ self.client.force_authenticate(user=self.normal_user) url = self.detail_url(self.location.id) diff --git a/MisplaceAI/rules/tests/test_rules.py b/MisplaceAI/rules/tests/test_rules.py index 33cdab6a64bc91b05fa2b5528982052d9669157b..c5937bbed22c655e5e69911913508b0ecbed01e1 100644 --- a/MisplaceAI/rules/tests/test_rules.py +++ b/MisplaceAI/rules/tests/test_rules.py @@ -1,18 +1,18 @@ # misplaceAI/rules/tests/test_rules.py """ -Test 1: test_create_rule - Test that a rule can be created with valid data by the owner. -Test 2: test_create_rule_with_invalid_data - Test that creating a rule with invalid data fails. -Test 3: test_create_rule_without_association - Test that creating a rule without locations fails. -Test 4: test_delete_rule_as_non_owner - Test that a non-owner cannot delete a rule. -Test 5: test_delete_rule_as_owner - Test that the owner can delete their rule. -Test 6: test_get_rule_detail_as_non_owner - Test that a non-owner cannot access the details of a rule. -Test 7: test_get_rule_detail_as_owner - Test that the owner can access the details of their rule. -Test 8: test_get_rules_as_non_owner - Test that a non-owner cannot access the list of rules of the owner. -Test 9: test_get_rules_as_owner - Test that the owner can access the list of their rules. -Test 10: test_rule_association_with_multiple_locations - Test that a rule can be associated with multiple locations. -Test 11: test_update_rule_as_non_owner - Test that a non-owner cannot update a rule. -Test 12: test_update_rule_as_owner - Test that the owner can update their rule. +Test ID-> RT1: test_create_rule - Test that a rule can be created with valid data by the owner. +Test ID-> RT2: test_create_rule_with_invalid_data - Test that creating a rule with invalid data fails. +Test ID-> RT3: test_create_rule_without_association - Test that creating a rule without locations fails. +Test ID-> RT4: test_delete_rule_as_non_owner - Test that a non-owner cannot delete a rule. +Test ID-> RT5: test_delete_rule_as_owner - Test that the owner can delete their rule. +Test ID-> RT6: test_get_rule_detail_as_non_owner - Test that a non-owner cannot access the details of a rule. +Test ID-> RT7: test_get_rule_detail_as_owner - Test that the owner can access the details of their rule. +Test ID-> RT8: test_get_rules_as_non_owner - Test that a non-owner cannot access the list of rules of the owner. +Test ID-> RT9: test_get_rules_as_owner - Test that the owner can access the list of their rules. +Test ID-> RT10: test_rule_association_with_multiple_locations - Test that a rule can be associated with multiple locations. +Test ID-> RT11: test_update_rule_as_non_owner - Test that a non-owner cannot update a rule. +Test ID-> RT12: test_update_rule_as_owner - Test that the owner can update their rule. """ from rest_framework import status @@ -46,7 +46,7 @@ class TestAdminManageRuleView(APITestCase): def test_create_rule(self): """ - Test 1: test_create_rule - Test that a rule can be created with valid data by the owner. + Test ID-> RT1: test_create_rule - Test that a rule can be created with valid data by the owner. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -65,7 +65,7 @@ class TestAdminManageRuleView(APITestCase): def test_create_rule_with_invalid_data(self): """ - Test 2: test_create_rule_with_invalid_data - Test that creating a rule with invalid data fails. + Test ID-> RT2: test_create_rule_with_invalid_data - Test that creating a rule with invalid data fails. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -84,7 +84,7 @@ class TestAdminManageRuleView(APITestCase): def test_create_rule_without_association(self): """ - Test 3: test_create_rule_without_association - Test that creating a rule without locations fails. + Test ID-> RT3: test_create_rule_without_association - Test that creating a rule without locations fails. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -103,7 +103,7 @@ class TestAdminManageRuleView(APITestCase): def test_delete_rule_as_non_owner(self): """ - Test 4: test_delete_rule_as_non_owner - Test that a non-owner cannot delete a rule. + Test ID-> RT4: test_delete_rule_as_non_owner - Test that a non-owner cannot delete a rule. """ # Authenticate as the non-owner self.client.force_authenticate(user=self.non_owner) @@ -116,7 +116,7 @@ class TestAdminManageRuleView(APITestCase): def test_delete_rule_as_owner(self): """ - Test 5: test_delete_rule_as_owner - Test that the owner can delete their rule. + Test ID-> RT5: test_delete_rule_as_owner - Test that the owner can delete their rule. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -129,7 +129,7 @@ class TestAdminManageRuleView(APITestCase): def test_get_rule_detail_as_non_owner(self): """ - Test 6: test_get_rule_detail_as_non_owner - Test that a non-owner cannot access the details of a rule. + Test ID-> RT6: test_get_rule_detail_as_non_owner - Test that a non-owner cannot access the details of a rule. """ # Authenticate as the non-owner self.client.force_authenticate(user=self.non_owner) @@ -142,7 +142,7 @@ class TestAdminManageRuleView(APITestCase): def test_get_rule_detail_as_owner(self): """ - Test 7: test_get_rule_detail_as_owner - Test that the owner can access the details of their rule. + Test ID-> RT7: test_get_rule_detail_as_owner - Test that the owner can access the details of their rule. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -158,7 +158,7 @@ class TestAdminManageRuleView(APITestCase): def test_get_rules_as_non_owner(self): """ - Test 8: test_get_rules_as_non_owner - Test that a non-owner cannot access the list of rules of the owner. + Test ID-> RT8: test_get_rules_as_non_owner - Test that a non-owner cannot access the list of rules of the owner. """ # Authenticate as the non-owner self.client.force_authenticate(user=self.non_owner) @@ -174,7 +174,7 @@ class TestAdminManageRuleView(APITestCase): def test_get_rules_as_owner(self): """ - Test 9: test_get_rules_as_owner - Test that the owner can access the list of their rules. + Test ID-> RT9: test_get_rules_as_owner - Test that the owner can access the list of their rules. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -193,7 +193,7 @@ class TestAdminManageRuleView(APITestCase): def test_rule_association_with_multiple_locations(self): """ - Test 10: test_rule_association_with_multiple_locations - Test that a rule can be associated with multiple locations. + Test ID-> RT10: test_rule_association_with_multiple_locations - Test that a rule can be associated with multiple locations. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) @@ -218,7 +218,7 @@ class TestAdminManageRuleView(APITestCase): def test_update_rule_as_non_owner(self): """ - Test 11: test_update_rule_as_non_owner - Test that a non-owner cannot update a rule. + Test ID-> RT11: test_update_rule_as_non_owner - Test that a non-owner cannot update a rule. """ # Authenticate as the non-owner self.client.force_authenticate(user=self.non_owner) @@ -241,7 +241,7 @@ class TestAdminManageRuleView(APITestCase): def test_update_rule_as_owner(self): """ - Test 12: test_update_rule_as_owner - Test that the owner can update their rule. + Test ID-> RT12: test_update_rule_as_owner - Test that the owner can update their rule. """ # Authenticate as the owner self.client.force_authenticate(user=self.owner) diff --git a/MisplaceAI/user_dashboard/tests/test_current_user_email.py b/MisplaceAI/user_dashboard/tests/test_current_user_email.py index 15a9f657c1eaae6c72ffe5198a01e91538cf90f7..1cceb8b3afc70e3a2f41d955a5ab034c8bfe6d73 100644 --- a/MisplaceAI/user_dashboard/tests/test_current_user_email.py +++ b/MisplaceAI/user_dashboard/tests/test_current_user_email.py @@ -1,10 +1,10 @@ # MisplaceAI/user_dashboard/tests/test_current_user_email.py """ -Test 1: Ensure an authenticated user can retrieve their current email. -Test 2: Ensure an unauthenticated user cannot retrieve their current email. -Test 3: Ensure the email retrieval returns the correct email format. -Test 4: Ensure an authenticated user with a different email can retrieve their current email. +Test ID-> E1: Ensure an authenticated user can retrieve their current email. +Test ID-> E2: Ensure an unauthenticated user cannot retrieve their current email. +Test ID-> E3: Ensure the email retrieval returns the correct email format. +Test ID-> E4: Ensure an authenticated user with a different email can retrieve their current email. """ from rest_framework.test import APITestCase @@ -19,7 +19,7 @@ class CurrentUserEmailViewTest(APITestCase): def test_current_user_email_view_authenticated(self): """ - Test 1: Ensure an authenticated user can retrieve their current email. + Test ID-> E1: Ensure an authenticated user can retrieve their current email. """ self.client.force_authenticate(user=self.user) url = reverse('user-current-email') @@ -29,16 +29,15 @@ class CurrentUserEmailViewTest(APITestCase): def test_current_user_email_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot retrieve their current email. + Test ID-> E2: Ensure an unauthenticated user cannot retrieve their current email. """ url = reverse('user-current-email') response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) - def test_email_retrieval_correct_format(self): """ - Test 3: Ensure the email retrieval returns the correct email format. + Test ID-> E3: Ensure the email retrieval returns the correct email format. """ self.client.force_authenticate(user=self.user) url = reverse('user-current-email') @@ -48,7 +47,7 @@ class CurrentUserEmailViewTest(APITestCase): def test_current_user_email_view_different_user(self): """ - Test 4: Ensure an authenticated user with a different email can retrieve their current email. + Test ID-> E4: Ensure an authenticated user with a different email can retrieve their current email. """ self.client.force_authenticate(user=self.user2) url = reverse('user-current-email') diff --git a/MisplaceAI/user_dashboard/tests/test_current_user_username.py b/MisplaceAI/user_dashboard/tests/test_current_user_username.py index 725c194b96a84e46749a2fc24e106e95b49a8b84..2e9a486416d04e760c57b9bf0261fc5408cc773a 100644 --- a/MisplaceAI/user_dashboard/tests/test_current_user_username.py +++ b/MisplaceAI/user_dashboard/tests/test_current_user_username.py @@ -1,10 +1,10 @@ # MisplaceAI/user_dashboard/tests/test_current_user_username.py """ -Test 1: Ensure an authenticated user can retrieve their current username. -Test 2: Ensure an unauthenticated user cannot retrieve their current username. -Test 3: Ensure the username retrieval returns the correct username format. -Test 4: Ensure an authenticated user with a different username can retrieve their current username. +Test ID-> U1: Ensure an authenticated user can retrieve their current username. +Test ID-> U2: Ensure an unauthenticated user cannot retrieve their current username. +Test ID-> U3: Ensure the username retrieval returns the correct username format. +Test ID-> U4: Ensure an authenticated user with a different username can retrieve their current username. """ from rest_framework.test import APITestCase @@ -20,7 +20,7 @@ class CurrentUserUsernameViewTest(APITestCase): def test_current_user_username_view_authenticated(self): """ - Test 1: Ensure an authenticated user can retrieve their current username. + Test ID-> U1: Ensure an authenticated user can retrieve their current username. """ url = reverse('user-current-username') response = self.client.get(url) @@ -29,17 +29,16 @@ class CurrentUserUsernameViewTest(APITestCase): def test_current_user_username_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot retrieve their current username. + Test ID-> U2: Ensure an unauthenticated user cannot retrieve their current username. """ self.client.logout() url = reverse('user-current-username') response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) - def test_username_retrieval_correct_format(self): """ - Test 3: Ensure the username retrieval returns the correct username format. + Test ID-> U3: Ensure the username retrieval returns the correct username format. """ self.client.force_authenticate(user=self.user) url = reverse('user-current-username') @@ -49,7 +48,7 @@ class CurrentUserUsernameViewTest(APITestCase): def test_current_user_username_view_different_user(self): """ - Test 4: Ensure an authenticated user with a different username can retrieve their current username. + Test ID-> U4: Ensure an authenticated user with a different username can retrieve their current username. """ self.client.force_authenticate(user=self.user2) url = reverse('user-current-username') diff --git a/MisplaceAI/user_dashboard/tests/test_update_email.py b/MisplaceAI/user_dashboard/tests/test_update_email.py index 784cb6e74527c8dfeb2aaaf8231b96ba91125ec9..cfe90b967b5106e84e20ed4b3bb1fa7045f63d76 100644 --- a/MisplaceAI/user_dashboard/tests/test_update_email.py +++ b/MisplaceAI/user_dashboard/tests/test_update_email.py @@ -1,15 +1,15 @@ # MisplaceAI/user_dashboard/tests/test_update_email.py """ -Test 1: Ensure an authenticated user can update their email. -Test 2: Ensure an unauthenticated user cannot update their email. -Test 3: Ensure email updates with the correct password. -Test 4: Ensure email updates fail with the incorrect password. -Test 5: Ensure invalid email format returns an error. -Test 6: Ensure updating to an already used email returns an error. -Test 7: Ensure an email update request without a password fails. -Test 8: Ensure an email update request with an empty email field fails. -Test 9: Ensure an email update request with an empty password field fails. +Test ID-> UE1: Ensure an authenticated user can update their email. +Test ID-> UE2: Ensure an unauthenticated user cannot update their email. +Test ID-> UE3: Ensure email updates with the correct password. +Test ID-> UE4: Ensure email updates fail with the incorrect password. +Test ID-> UE5: Ensure invalid email format returns an error. +Test ID-> UE6: Ensure updating to an already used email returns an error. +Test ID-> UE7: Ensure an email update request without a password fails. +Test ID-> UE8: Ensure an email update request with an empty email field fails. +Test ID-> UE9: Ensure an email update request with an empty password field fails. """ from rest_framework.test import APITestCase @@ -24,7 +24,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_view_authenticated(self): """ - Test 1: Ensure an authenticated user can update their email. + Test ID-> UE1: Ensure an authenticated user can update their email. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -34,7 +34,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot update their email. + Test ID-> UE2: Ensure an unauthenticated user cannot update their email. """ url = reverse('user-update-email') data = {'email': 'newemail@example.com', 'password': 'testpassword'} @@ -43,7 +43,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_with_correct_password(self): """ - Test 3: Ensure email updates with the correct password. + Test ID-> UE3: Ensure email updates with the correct password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -53,7 +53,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_with_wrong_password(self): """ - Test 4: Ensure email updates fail with the incorrect password. + Test ID-> UE4: Ensure email updates fail with the incorrect password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -63,7 +63,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_with_invalid_email(self): """ - Test 5: Ensure invalid email format returns an error. + Test ID-> UE5: Ensure invalid email format returns an error. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -73,7 +73,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_to_existing_email(self): """ - Test 6: Ensure updating to an already used email returns an error. + Test ID-> UE6: Ensure updating to an already used email returns an error. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -83,7 +83,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_without_password(self): """ - Test 7: Ensure an email update request without a password fails. + Test ID-> UE7: Ensure an email update request without a password fails. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -93,7 +93,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_with_empty_email_field(self): """ - Test 8: Ensure an email update request with an empty email field fails. + Test ID-> UE8: Ensure an email update request with an empty email field fails. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') @@ -103,7 +103,7 @@ class UpdateEmailViewTest(APITestCase): def test_update_email_with_empty_password_field(self): """ - Test 9: Ensure an email update request with an empty password field fails. + Test ID-> UE9: Ensure an email update request with an empty password field fails. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-email') diff --git a/MisplaceAI/user_dashboard/tests/test_update_password.py b/MisplaceAI/user_dashboard/tests/test_update_password.py index c79b88d05150423565401932b52820cc86852d6d..aa339cf419dc2f84a7c88dcdfd34d4f169a4e026 100644 --- a/MisplaceAI/user_dashboard/tests/test_update_password.py +++ b/MisplaceAI/user_dashboard/tests/test_update_password.py @@ -1,16 +1,14 @@ # MisplaceAI/user_dashboard/tests/test_update_password.py - """ -Test 1: Ensure an authenticated user can update their password. -Test 2: Ensure an unauthenticated user cannot update their password. -Test 3: Ensure password updates with the correct current password. -Test 4: Ensure password updates fail with the wrong current password. -Test 5: Ensure password updates fail when new passwords do not match. -Test 6: Ensure password updates fail with invalid new password format. +Test ID-> UP1: Ensure an authenticated user can update their password. +Test ID-> UP2: Ensure an unauthenticated user cannot update their password. +Test ID-> UP3: Ensure password updates with the correct current password. +Test ID-> UP4: Ensure password updates fail with the wrong current password. +Test ID-> UP5: Ensure password updates fail when new passwords do not match. +Test ID-> UP6: Ensure password updates fail with invalid new password format. """ - from django.contrib.auth.models import User from rest_framework import status from rest_framework.reverse import reverse @@ -22,7 +20,7 @@ class UpdatePasswordViewTest(APITestCase): def test_update_password_view_authenticated(self): """ - Test 1: Ensure an authenticated user can update their password. + Test ID-> UP1: Ensure an authenticated user can update their password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-password') @@ -36,7 +34,7 @@ class UpdatePasswordViewTest(APITestCase): def test_update_password_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot update their password. + Test ID-> UP2: Ensure an unauthenticated user cannot update their password. """ url = reverse('user-update-password') data = { @@ -47,10 +45,9 @@ class UpdatePasswordViewTest(APITestCase): response = self.client.put(url, data, format='json') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) - def test_update_password_with_correct_current_password(self): """ - Test 3: Ensure password updates with the correct current password. + Test ID-> UP3: Ensure password updates with the correct current password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-password') @@ -64,7 +61,7 @@ class UpdatePasswordViewTest(APITestCase): def test_update_password_with_wrong_current_password(self): """ - Test 4: Ensure password updates fail with the wrong current password. + Test ID-> UP4: Ensure password updates fail with the wrong current password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-password') @@ -80,7 +77,7 @@ class UpdatePasswordViewTest(APITestCase): def test_update_password_with_mismatched_new_passwords(self): """ - Test 5: Ensure password updates fail when new passwords do not match. + Test ID-> UP5: Ensure password updates fail when new passwords do not match. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-password') @@ -96,7 +93,7 @@ class UpdatePasswordViewTest(APITestCase): def test_update_password_with_invalid_new_password_format(self): """ - Test 6: Ensure password updates fail with invalid new password format. + Test ID-> UP6: Ensure password updates fail with invalid new password format. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-password') diff --git a/MisplaceAI/user_dashboard/tests/test_update_username.py b/MisplaceAI/user_dashboard/tests/test_update_username.py index 600c872ae7b1f9f906d86a2592be3f75aeaf7d94..c2903ba16f544d3d01154355fbae9448caa33e67 100644 --- a/MisplaceAI/user_dashboard/tests/test_update_username.py +++ b/MisplaceAI/user_dashboard/tests/test_update_username.py @@ -1,15 +1,15 @@ # MisplaceAI/user_dashboard/tests/test_update_username.py """ -Test 1: Ensure an authenticated user can update their username. -Test 2: Ensure an unauthenticated user cannot update their username. -Test 3: Ensure username updates fail with invalid data. -Test 4: Ensure username updates fail without providing a password. -Test 5: Ensure username updates fail with an incorrect password. -Test 6: Ensure username updates respect case sensitivity. -Test 7: Ensure username updates fail if the username is too long. -Test 8: Ensure username updates fail if the username is too short. -Test 9: Ensure a user cannot update their username to a username that already exists. +Test ID-> UU1: Ensure an authenticated user can update their username. +Test ID-> UU2: Ensure an unauthenticated user cannot update their username. +Test ID-> UU3: Ensure username updates fail with invalid data. +Test ID-> UU4: Ensure username updates fail without providing a password. +Test ID-> UU5: Ensure username updates fail with an incorrect password. +Test ID-> UU6: Ensure username updates respect case sensitivity. +Test ID-> UU7: Ensure username updates fail if the username is too long. +Test ID-> UU8: Ensure username updates fail if the username is too short. +Test ID-> UU9: Ensure a user cannot update their username to a username that already exists. """ from rest_framework.test import APITestCase @@ -24,7 +24,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_view_authenticated(self): """ - Test 1: Ensure an authenticated user can update their username. + Test ID-> UU1: Ensure an authenticated user can update their username. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -36,7 +36,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot update their username. + Test ID-> UU2: Ensure an unauthenticated user cannot update their username. """ url = reverse('user-update-username') data = {'username': 'newusername', 'password': 'testpassword'} @@ -45,7 +45,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_with_invalid_data(self): """ - Test 3: Ensure username updates fail with invalid data. + Test ID-> UU3: Ensure username updates fail with invalid data. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -55,7 +55,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_without_password(self): """ - Test 4: Ensure username updates fail without providing a password. + Test ID-> UU4: Ensure username updates fail without providing a password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -65,7 +65,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_with_incorrect_password(self): """ - Test 5: Ensure username updates fail with an incorrect password. + Test ID-> UU5: Ensure username updates fail with an incorrect password. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -75,7 +75,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_case_sensitivity(self): """ - Test 6: Ensure username updates respect case sensitivity. + Test ID-> UU6: Ensure username updates respect case sensitivity. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -87,7 +87,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_too_long(self): """ - Test 7: Ensure username updates fail if the username is too long. + Test ID-> UU7: Ensure username updates fail if the username is too long. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -97,7 +97,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_too_short(self): """ - Test 8: Ensure username updates fail if the username is too short. + Test ID-> UU8: Ensure username updates fail if the username is too short. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') @@ -107,7 +107,7 @@ class UpdateUsernameViewTest(APITestCase): def test_update_username_to_existing_username(self): """ - Test 9: Ensure a user cannot update their username to a username that already exists. + Test ID-> UU9: Ensure a user cannot update their username to a username that already exists. """ self.client.force_authenticate(user=self.user) url = reverse('user-update-username') diff --git a/MisplaceAI/user_dashboard/tests/test_user_dashboard.py b/MisplaceAI/user_dashboard/tests/test_user_dashboard.py index 96c2500f39e74efa407e08ea0821fe5002436620..99b3b04aba442eb506c26ffe4c51da2f6b818289 100644 --- a/MisplaceAI/user_dashboard/tests/test_user_dashboard.py +++ b/MisplaceAI/user_dashboard/tests/test_user_dashboard.py @@ -1,11 +1,11 @@ # MisplaceAI/user_dashboard/tests/test_user_dashboard.py """ -Test 1: Ensure an authenticated user can retrieve their dashboard information. -Test 2: Ensure an unauthenticated user cannot retrieve dashboard information. -Test 3: Ensure an authenticated user can retrieve their full profile details. -Test 4: Ensure retrieving the dashboard information includes the user's email. -Test 5: Ensure retrieving the dashboard information includes the user's first name and last name. +Test ID-> UD1: Ensure an authenticated user can retrieve their dashboard information. +Test ID-> UD2: Ensure an unauthenticated user cannot retrieve dashboard information. +Test ID-> UD3: Ensure an authenticated user can retrieve their full profile details. +Test ID-> UD4: Ensure retrieving the dashboard information includes the user's email. +Test ID-> UD5: Ensure retrieving the dashboard information includes the user's first name and last name. """ from rest_framework.test import APITestCase @@ -25,7 +25,7 @@ class UserDashboardViewTest(APITestCase): def test_user_dashboard_view_authenticated(self): """ - Test 1: Ensure an authenticated user can retrieve their dashboard information. + Test ID-> UD1: Ensure an authenticated user can retrieve their dashboard information. """ self.client.force_authenticate(user=self.user) url = reverse('user-dashboard') @@ -35,7 +35,7 @@ class UserDashboardViewTest(APITestCase): def test_user_dashboard_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot retrieve dashboard information. + Test ID-> UD2: Ensure an unauthenticated user cannot retrieve dashboard information. """ url = reverse('user-dashboard') response = self.client.get(url) @@ -43,7 +43,7 @@ class UserDashboardViewTest(APITestCase): def test_user_dashboard_view_full_profile(self): """ - Test 3: Ensure an authenticated user can retrieve their full profile details. + Test ID-> UD3: Ensure an authenticated user can retrieve their full profile details. """ self.client.force_authenticate(user=self.user) url = reverse('user-dashboard') @@ -56,7 +56,7 @@ class UserDashboardViewTest(APITestCase): def test_user_dashboard_includes_email(self): """ - Test 4: Ensure retrieving the dashboard information includes the user's email. + Test ID-> UD4: Ensure retrieving the dashboard information includes the user's email. """ self.client.force_authenticate(user=self.user) url = reverse('user-dashboard') @@ -67,7 +67,7 @@ class UserDashboardViewTest(APITestCase): def test_user_dashboard_includes_name(self): """ - Test 5: Ensure retrieving the dashboard information includes the user's first name and last name. + Test ID-> UD5: Ensure retrieving the dashboard information includes the user's first name and last name. """ self.client.force_authenticate(user=self.user) url = reverse('user-dashboard') diff --git a/MisplaceAI/user_dashboard/tests/test_user_update.py b/MisplaceAI/user_dashboard/tests/test_user_update.py index 4e7884647a0ed09b0b49386d37cb4001c52affb4..887a2ba088791e6c2cb45c215536c98d86d33c0a 100644 --- a/MisplaceAI/user_dashboard/tests/test_user_update.py +++ b/MisplaceAI/user_dashboard/tests/test_user_update.py @@ -1,5 +1,12 @@ # MisplaceAI/user_dashboard/tests/test_user_update.py +""" +Test ID-> UU1: Ensure an authenticated user can update their information. +Test ID-> UU2: Ensure an unauthenticated user cannot update information. +Test ID-> UU3: Ensure invalid data returns appropriate errors. +Test ID-> UU4: Ensure partial updates work correctly for authenticated users. +""" + from rest_framework.test import APITestCase from rest_framework import status from django.contrib.auth.models import User @@ -11,7 +18,7 @@ class UserUpdateViewTest(APITestCase): def test_user_update_view_authenticated(self): """ - Test 1: Ensure an authenticated user can update their information. + Test ID-> UU1: Ensure an authenticated user can update their information. """ self.client.force_authenticate(user=self.user) url = reverse('user-update') @@ -22,7 +29,7 @@ class UserUpdateViewTest(APITestCase): def test_user_update_view_unauthenticated(self): """ - Test 2: Ensure an unauthenticated user cannot update information. + Test ID-> UU2: Ensure an unauthenticated user cannot update information. """ url = reverse('user-update') data = {'username': 'updateduser'} @@ -31,7 +38,7 @@ class UserUpdateViewTest(APITestCase): def test_user_update_view_invalid_data(self): """ - Test 3: Ensure invalid data returns appropriate errors. + Test ID-> UU3: Ensure invalid data returns appropriate errors. """ self.client.force_authenticate(user=self.user) url = reverse('user-update') @@ -41,7 +48,7 @@ class UserUpdateViewTest(APITestCase): def test_user_update_view_partial_update(self): """ - Test 4: Ensure partial updates work correctly for authenticated users. + Test ID-> UU4: Ensure partial updates work correctly for authenticated users. """ self.client.force_authenticate(user=self.user) url = reverse('user-update')