diff --git a/backend/api/logic/parse_zip_files.py b/backend/api/logic/parse_zip_files.py index e1f3ee8e..9ec68de3 100644 --- a/backend/api/logic/parse_zip_files.py +++ b/backend/api/logic/parse_zip_files.py @@ -24,7 +24,7 @@ def parse_zip(project: Project, zip_file: InMemoryUploadedFile) -> bool: if common_prefix[-1] != '/': prefixes = prefixes[:-1] - directories += [prefix for prefix in prefixes] + directories += [f"{prefix}/" for prefix in prefixes] # Add for each directory a structure check for directory in directories: @@ -41,7 +41,7 @@ def parse_zip(project: Project, zip_file: InMemoryUploadedFile) -> bool: def create_check(project: Project, directory_path: str, files: list[str]): check = StructureCheck.objects.create( - path=directory_path, + path=directory_path[:-1], project=project ) diff --git a/backend/api/tests/test_file_structure.py b/backend/api/tests/test_file_structure.py index be463dee..ad484acd 100644 --- a/backend/api/tests/test_file_structure.py +++ b/backend/api/tests/test_file_structure.py @@ -56,37 +56,37 @@ def test_parsing(self): ) content = content_json[0] - self.assertEqual(content["path"], "folder_struct1/submap1/") + self.assertEqual(content["path"], "folder_struct1/submap1") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 2) self.assertEqual(len(content["blocked_extensions"]), 0) content = content_json[1] - self.assertEqual(content["path"], "folder_struct1/submap1/templates/") + self.assertEqual(content["path"], "folder_struct1/submap1/templates") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 1) self.assertEqual(len(content["blocked_extensions"]), 0) content = content_json[2] - self.assertEqual(content["path"], "folder_struct1/submap2/") + self.assertEqual(content["path"], "folder_struct1/submap2") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 1) self.assertEqual(len(content["blocked_extensions"]), 0) content = content_json[3] - self.assertEqual(content["path"], "folder_struct1/submap2/src/") + self.assertEqual(content["path"], "folder_struct1/submap2/src") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 3) self.assertEqual(len(content["blocked_extensions"]), 0) content = content_json[4] - self.assertEqual(content["path"], "folder_struct1/submap3/") + self.assertEqual(content["path"], "folder_struct1/submap3") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 2) self.assertEqual(len(content["blocked_extensions"]), 0) content = content_json[5] - self.assertEqual(content["path"], "folder_struct1/") + self.assertEqual(content["path"], "folder_struct1") self.assertEqual(content["project"], expected_project_url) self.assertEqual(len(content["obligated_extensions"]), 1) self.assertEqual(len(content["blocked_extensions"]), 0)