diff --git a/.flake8 b/.flake8 index 8283733..bd79a42 100644 --- a/.flake8 +++ b/.flake8 @@ -2,3 +2,5 @@ max-line-length = 88 extend-ignore = E203, W503 exclude = reference/, .git, __pycache__, web/, venv/, htmlcov/, build/, dist/ +per-file-ignores = + tests/*:E402 diff --git a/tests/test_validators.py b/tests/test_validators.py index 8f1707e..278ab10 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -16,7 +16,6 @@ from utils.validators import ( validate_rating, validate_tags, validate_category, - validate_workflow_name, sanitize_input, parse_tags_string, validate_result_timeout, @@ -77,41 +76,6 @@ class TestValidateCategory(unittest.TestCase): validate_category("bad\ncategory") -class TestValidateWorkflowName(unittest.TestCase): - """Test validate_workflow_name function.""" - - def test_none_is_valid(self): - self.assertTrue(validate_workflow_name(None)) - - def test_empty_string_is_valid(self): - self.assertTrue(validate_workflow_name("")) - - def test_whitespace_only_is_valid(self): - self.assertTrue(validate_workflow_name(" ")) - - def test_normal_name(self): - self.assertTrue(validate_workflow_name("My Workflow")) - - def test_name_with_special_chars(self): - self.assertTrue(validate_workflow_name("workflow-v2_final (copy)")) - - def test_max_length_boundary(self): - self.assertTrue(validate_workflow_name("x" * 200)) - - def test_exceeds_max_length(self): - with self.assertRaises(ValueError) as ctx: - validate_workflow_name("x" * 201) - self.assertIn("200", str(ctx.exception)) - - def test_non_string_raises(self): - with self.assertRaises(ValueError): - validate_workflow_name(42) - - def test_dict_raises(self): - with self.assertRaises(ValueError): - validate_workflow_name({"name": "workflow"}) - - class TestSanitizeInput(unittest.TestCase): """Test sanitize_input function.""" diff --git a/utils/validators.py b/utils/validators.py index cd6aa1c..5d98157 100644 --- a/utils/validators.py +++ b/utils/validators.py @@ -148,7 +148,8 @@ def validate_tags(tags: Union[str, List[str], None]) -> bool: - Wrong input type (not string, list, or None) - Individual tag is empty or only whitespace - Individual tag exceeds 50 characters - - Tag contains invalid characters (non-alphanumeric, spaces, hyphens, underscores) + - Tag contains characters other than alphanumerics, + spaces, hyphens and underscores - More than 20 tags provided """ if tags is None: @@ -199,7 +200,8 @@ def validate_category(category: Optional[str]) -> bool: ValueError: If category is invalid: - Not a string type (when not None) - Exceeds 100 characters - - Contains invalid characters (non-alphanumeric, spaces, hyphens, underscores) + - Contains characters other than alphanumerics, spaces, + hyphens and underscores """ if category is None: return True @@ -221,40 +223,6 @@ def validate_category(category: Optional[str]) -> bool: return True -def validate_workflow_name(workflow_name: Optional[str]) -> bool: - """ - Validate workflow name input. - - Validates optional workflow name strings with generous length limits - to accommodate descriptive workflow names. - - Args: - workflow_name: The workflow name to validate (None allowed for no workflow) - - Returns: - True if the workflow name is valid or None - - Raises: - ValueError: If workflow name is invalid: - - Not a string type (when not None) - - Exceeds 200 characters - """ - if workflow_name is None: - return True - - if not isinstance(workflow_name, str): - raise ValueError("Workflow name must be a string") - - workflow_name = workflow_name.strip() - if not workflow_name: - return True # Empty workflow name is valid - - if len(workflow_name) > 200: - raise ValueError("Workflow name cannot exceed 200 characters") - - return True - - def sanitize_input(text: str) -> str: """ Sanitize text input by removing potentially harmful content.