Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed May 24, 2024
1 parent 891ddbc commit 35619f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions backend/api/logic/parse_zip_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
)

Expand Down
12 changes: 6 additions & 6 deletions backend/api/tests/test_file_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 35619f7

Please sign in to comment.