From 63b262920a32a99237d2fd9aeef9d679c9b1ed98 Mon Sep 17 00:00:00 2001 From: Lukas Barragan Torres Date: Thu, 23 May 2024 20:09:11 +0200 Subject: [PATCH 1/4] change name of extension not present constraint --- .../constraints/extension_not_present_constraint.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/domain/simple_submission_checks/constraints/extension_not_present_constraint.py b/backend/domain/simple_submission_checks/constraints/extension_not_present_constraint.py index 864cb750..1a5ddcbb 100644 --- a/backend/domain/simple_submission_checks/constraints/extension_not_present_constraint.py +++ b/backend/domain/simple_submission_checks/constraints/extension_not_present_constraint.py @@ -11,22 +11,22 @@ class ExtensionNotPresentConstraint(BaseModel): type: ConstraintType = ConstraintType.EXTENSION_NOT_PRESENT - extension: str + not_present_extension: str def validate_constraint(self, path: Path) -> ExtensionNotPresentConstraintResult: directory = os.listdir(path) - files_with_extension = [file for file in directory if file.endswith(self.extension)] + files_with_extension = [file for file in directory if file.endswith(self.not_present_extension)] if files_with_extension: return ExtensionNotPresentConstraintResult( - extension=self.extension, + extension=self.not_present_extension, is_ok=False, files_with_extension=files_with_extension, ) return ExtensionNotPresentConstraintResult( - extension=self.extension, + extension=self.not_present_extension, is_ok=True, files_with_extension=files_with_extension, ) From 43373b335e7b82cd514fd650d7e9150330fba91e Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 23 May 2024 20:12:46 +0200 Subject: [PATCH 2/4] extension to not_present_extension" --- frontend/src/components/SimpleTests/SimpleTests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/SimpleTests/SimpleTests.tsx b/frontend/src/components/SimpleTests/SimpleTests.tsx index c9c95c86..9b648da2 100644 --- a/frontend/src/components/SimpleTests/SimpleTests.tsx +++ b/frontend/src/components/SimpleTests/SimpleTests.tsx @@ -194,7 +194,7 @@ function submission_to_json(submission: Submission): object { constraint_object['file_or_directory_name'] = constraint.value; break; case 'EXTENSION_NOT_PRESENT': - constraint_object['extension'] = constraint.value; + constraint_object['not_present_extension'] = constraint.value; break; case 'EXTENSION_ONLY_PRESENT': constraint_object['extension'] = constraint.value; From 5a7a88707ca1da747782ed2e4672f6a777675bc6 Mon Sep 17 00:00:00 2001 From: Lukas Barragan Torres Date: Thu, 23 May 2024 20:20:50 +0200 Subject: [PATCH 3/4] extension -> not_present_extension in tests --- .../test_simple_submissions/test_everything_not_ok.py | 4 ++-- .../tests/test_simple_submissions/test_everything_ok.py | 6 +++--- .../test_extension_not_present_constraint.py | 9 +++++---- .../test_simple_submissions/test_global_constraint.py | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/tests/test_simple_submissions/test_everything_not_ok.py b/backend/tests/test_simple_submissions/test_everything_not_ok.py index 1736b29a..14833f8c 100644 --- a/backend/tests/test_simple_submissions/test_everything_not_ok.py +++ b/backend/tests/test_simple_submissions/test_everything_not_ok.py @@ -50,7 +50,7 @@ class FaultyProjectConstraintValidationTest(unittest.TestCase): submission_constraint = SubmissionConstraint( root_constraint=ZipConstraint( zip_name="project.zip", - global_constraints=[ExtensionNotPresentConstraint(extension=".exe")], + global_constraints=[ExtensionNotPresentConstraint(not_present_extension=".exe")], sub_constraints=[ DirectoryConstraint( directory_name="src", @@ -72,7 +72,7 @@ class FaultyProjectConstraintValidationTest(unittest.TestCase): FileConstraint(file_name="README.md"), FileConstraint(file_name=".gitignore"), NotPresentConstraint(file_or_directory_name="dist"), - ExtensionNotPresentConstraint(extension=".log"), + ExtensionNotPresentConstraint(not_present_extension=".log"), ], ), ) diff --git a/backend/tests/test_simple_submissions/test_everything_ok.py b/backend/tests/test_simple_submissions/test_everything_ok.py index 25dd3b27..7fafdb96 100644 --- a/backend/tests/test_simple_submissions/test_everything_ok.py +++ b/backend/tests/test_simple_submissions/test_everything_ok.py @@ -45,7 +45,7 @@ class EverythingOkTest(unittest.TestCase): submission_constraint = SubmissionConstraint( root_constraint=ZipConstraint( zip_name="project.zip", - global_constraints=[ExtensionNotPresentConstraint(extension=".exe")], + global_constraints=[ExtensionNotPresentConstraint(not_present_extension=".exe")], sub_constraints=[ DirectoryConstraint( directory_name="src", @@ -71,8 +71,8 @@ class EverythingOkTest(unittest.TestCase): FileConstraint(file_name="README.md"), FileConstraint(file_name=".gitignore"), NotPresentConstraint(file_or_directory_name="dist"), - ExtensionNotPresentConstraint(extension=".class"), - ExtensionNotPresentConstraint(extension=".log"), + ExtensionNotPresentConstraint(not_present_extension=".class"), + ExtensionNotPresentConstraint(not_present_extension=".log"), ], ), ) diff --git a/backend/tests/test_simple_submissions/test_extension_not_present_constraint.py b/backend/tests/test_simple_submissions/test_extension_not_present_constraint.py index c53c4912..7417fa7e 100644 --- a/backend/tests/test_simple_submissions/test_extension_not_present_constraint.py +++ b/backend/tests/test_simple_submissions/test_extension_not_present_constraint.py @@ -44,12 +44,13 @@ class ExtensionNotPresentConstraintValidationTest(unittest.TestCase): zip_name="submission.zip", global_constraints=[], sub_constraints=[ - ExtensionNotPresentConstraint(extension=".java"), # .java is present, should fail - ExtensionNotPresentConstraint(extension=".c"), # .c is present, should fail - ExtensionNotPresentConstraint(extension=".cpp"), # .cpp is not present, should pass + ExtensionNotPresentConstraint(not_present_extension=".java"), # .java is present, should fail + ExtensionNotPresentConstraint(not_present_extension=".c"), # .c is present, should fail + ExtensionNotPresentConstraint(not_present_extension=".cpp"), # .cpp is not present, should pass DirectoryConstraint( # Directory is present, should pass directory_name="no_txt_in_this_folder", - sub_constraints=[ExtensionNotPresentConstraint(extension=".txt")], # .txt is present, should fail + sub_constraints=[ExtensionNotPresentConstraint(not_present_extension=".txt")], # .txt is + # present, should fail ), ], ), diff --git a/backend/tests/test_simple_submissions/test_global_constraint.py b/backend/tests/test_simple_submissions/test_global_constraint.py index e3a7388e..3e7ef346 100644 --- a/backend/tests/test_simple_submissions/test_global_constraint.py +++ b/backend/tests/test_simple_submissions/test_global_constraint.py @@ -35,9 +35,9 @@ class GlobalConstraintValidationTest(unittest.TestCase): root_constraint=ZipConstraint( zip_name="submission.zip", global_constraints=[ - ExtensionNotPresentConstraint(extension=".java"), - ExtensionNotPresentConstraint(extension=".c"), - ExtensionNotPresentConstraint(extension=".cpp"), + ExtensionNotPresentConstraint(not_present_extension=".java"), + ExtensionNotPresentConstraint(not_present_extension=".c"), + ExtensionNotPresentConstraint(not_present_extension=".cpp"), NotPresentConstraint(file_or_directory_name="dir4"), ], sub_constraints=[], From c1a84a4cd010542a0a9b63348cfadcd1c3b46a7e Mon Sep 17 00:00:00 2001 From: Ruben Vandamme Date: Thu, 23 May 2024 20:21:58 +0200 Subject: [PATCH 4/4] do it everywhere --- frontend/src/components/SimpleTests/SimpleTests.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/SimpleTests/SimpleTests.tsx b/frontend/src/components/SimpleTests/SimpleTests.tsx index 9b648da2..fb4d4d14 100644 --- a/frontend/src/components/SimpleTests/SimpleTests.tsx +++ b/frontend/src/components/SimpleTests/SimpleTests.tsx @@ -105,7 +105,7 @@ function json_to_submission(json: any): Submission { break; } case 'EXTENSION_NOT_PRESENT': { - constraint = new Constraint('EXTENSION_NOT_PRESENT', json['extension'], id, parent_id, depth); + constraint = new Constraint('EXTENSION_NOT_PRESENT', json['not_present_extension'], id, parent_id, depth); break; } case 'EXTENSION_ONLY_PRESENT': { @@ -147,7 +147,7 @@ function json_to_submission(json: any): Submission { break; } case 'EXTENSION_NOT_PRESENT': { - constraint = new Constraint('EXTENSION_NOT_PRESENT', json['extension'], id, undefined, 0); + constraint = new Constraint('EXTENSION_NOT_PRESENT', json['not_present_extension'], id, undefined, 0); break; } case 'EXTENSION_ONLY_PRESENT': {